hotcoffee
March 25th, 1999, 04:34 AM
How to handle the messages for controls which created at run time?
(Include windows stardard control and ActiveX control)
(Include windows stardard control and ActiveX control)
|
Click to See Complete Forum and Search --> : How to handle the messages for controls which created at run time? hotcoffee March 25th, 1999, 04:34 AM How to handle the messages for controls which created at run time? (Include windows stardard control and ActiveX control) Ravi Kiran March 25th, 1999, 04:58 AM Hi, I guess, you mean 'events' raised from the controls? Only way as i know is to have a member variable of the same type and use set method when you create a run-time instance. The varibale should have a module-level (global) scope. Ex: Suppose you have a control, StateChangingControl ,that raises some StateChanged(NewState,OldState) event. To be able to handle this event you need something like this: In the declaration section of Form/Class have a line: private WithEvents m_mycontrol as StateChangingControl and when you create a new runtime instance use: ... set m_mycontrol = new StateChangingControl ... With 'WithEvents' command, if VB detects any events associated with this StateChangingControl , it automatically lists them in the methods combobox. You should see the member 'm_mycontrol' in the controls (LHS) combo (on the Editor)and when you select this, you should see the event 'StateChanged' in the methods (RHS) combo . And when you select 'StateChanged' from this list, VB will create a stub like: private sub m_mycontrol_StateChanged(NewState,OldState) end sub and the respective types of the params would also be present. Try a simple code : private withevents m_mytimer as Timer and it would work like a timer-control of VB I hope it was not a long answer for a not-required topic! :-) Ravi codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |