|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
User Control SubclassingI am writing a usercontrol to work with a multithreaded .dll, and I am using subclassing to intercept messages back from the .dll. Subclassing requires that I pass a window-handle to the .dll so that the .dll knows where to send messages back to, so I added a form to the UserControl project to handle messages. So, when certain messages come through to the form, I want to raise an event in the UserControl object. The problem is that when I call the "RaiseEvent" keyword in the form object, I get a message saying that the event that I am trying to call does not exist. In reality, the Event that I'm trying to raise just doesn't exist in the form object - but is does exist in the UserControl object. How can I make the form throw events in the UserControl scope? Thanks for your help! -Joel Whitehouse "Joel Whitehouse" <joelwhiteho***@gmail.com> wrote in message news:ur3he.78091$WI3.22015@attbi_s71> How can I make the form You need to> throw events in the UserControl scope? a) define the event in the form b) have the usercontrol declare the form reference "WithEvents" c) raise the event in the form d) respond to the event in the usercontrol and raise the event again from there -or- have some other callback mechanism from the form to the usercontrol to tell it to raise the event -- Reply to the group so all can participate VB.Net: "Fool me once..." Bob Butler wrote:>
> You need to Thanks Bob. I'm lookink into "withevents" right now.> a) define the event in the form > b) have the usercontrol declare the form reference "WithEvents" > c) raise the event in the form > d) respond to the event in the usercontrol and raise the event again from > there > have some other callback mechanism from the form to the usercontrol to tell I tried the callback, but it had to be public, and it exposed too much > it to raise the event of the UserControl's inner workings to the user... "Joel Whitehouse" <joelwhiteho***@gmail.com> wrote in message news:LT3he.78116$WI3.65850@attbi_s71 >> have some other callback mechanism from the form to the usercontrol Did you try 'Friend' ? >> to tell it to raise the event > I tried the callback, but it had to be public, and it exposed too much > of the UserControl's inner workings to the user... BTW, I agree with Ken that if you can get rid of the form that'd be best -- Reply to the group so all can participate VB.Net: "Fool me once..." "Joel Whitehouse" <joelwhiteho***@gmail.com> wrote in message news:ur3he.78091$WI3.22015@attbi_s71...> Hello All, In the usercontrol, you can add a public sub that fires an event and call > > I am writing a usercontrol to work with a multithreaded .dll, and I am > using subclassing to intercept messages back from the .dll. Subclassing > requires that I pass a window-handle to the .dll so that the .dll knows > where to send messages back to, so I added a form to the UserControl > project to handle messages. that from the form. '======= Public Event FireONE(SomeText As String) Public Sub RaiseTheEvent(SomeInfo As String) RaiseEvent FireONE(SomeInfo) End Sub '======= Why add a form though? Why not pass the handle to the UserControl? -- Ken Halter - MS-MVP-VB - http://www.vbsight.com DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm Sign up now to help keep VB support alive - http://classicvb.org/petition Please keep all discussions in the groups.. > I wasn't aware that a UserControl hWnd would function correctly. I'll > Why add a form though? Why not pass the handle to the UserControl? > try it out.
Other interesting topics
|
|||||||||||||||||||||||