Cableguy Expert Licensed User Longtime User Apr 24, 2010 #1 Hi guys... I have a few modules in a project of mine and I am tiding things up... I have a module called "components" were I create all controls in runtime and add all DLL objects I require... Now I was hopping to move all the controls and Objects SUBs to the main module, so that only the initialization of the components were in the components module... I added FormLib to allow me to change the parent of a control, so far so good, now I'm getting this message when I try to change the parent of a Timer created in the components module to the Main module form: Object of type 'DBasic.EnhancedControls.CEnhancedTimer' cannot be converted to type 'System.Windows.Forms.Control' Click to expand... Why? I want to be able to execute an event in a diferent module of the one the control was created on...How?
Hi guys... I have a few modules in a project of mine and I am tiding things up... I have a module called "components" were I create all controls in runtime and add all DLL objects I require... Now I was hopping to move all the controls and Objects SUBs to the main module, so that only the initialization of the components were in the components module... I added FormLib to allow me to change the parent of a control, so far so good, now I'm getting this message when I try to change the parent of a Timer created in the components module to the Main module form: Object of type 'DBasic.EnhancedControls.CEnhancedTimer' cannot be converted to type 'System.Windows.Forms.Control' Click to expand... Why? I want to be able to execute an event in a diferent module of the one the control was created on...How?
Erel B4X founder Staff member Licensed User Longtime User Apr 24, 2010 #2 Timer doesn't really have a parent form. It is a global "control". So you can't move it between forms and actually it doesn't really matter as you can use it everywhere you need.
Timer doesn't really have a parent form. It is a global "control". So you can't move it between forms and actually it doesn't really matter as you can use it everywhere you need.
Cableguy Expert Licensed User Longtime User Apr 24, 2010 #3 But I tried firing the tick event from the main module an it errors... it never gets fired
Erel B4X founder Staff member Licensed User Longtime User Apr 24, 2010 #4 You should use AddEvent. In this example I have a timer in a module named mm. Code: Copy Sub App_Start Form1.Show AddEvent("mm.timer1", Tick, "Timer1FromDifferentModule_tick") mm.Timer1.Enabled = True End Sub Sub Timer1FromDifferentModule_tick form1.Text = TimeS End Sub
You should use AddEvent. In this example I have a timer in a module named mm. Code: Copy Sub App_Start Form1.Show AddEvent("mm.timer1", Tick, "Timer1FromDifferentModule_tick") mm.Timer1.Enabled = True End Sub Sub Timer1FromDifferentModule_tick form1.Text = TimeS End Sub
Cableguy Expert Licensed User Longtime User Apr 24, 2010 #5 Of course!!!!!!! I had forgot the AddEvent Keyword!!!!.... But can I use it this way? AddEvent("timer1", Tick, "mm.Timer1FromDifferentModule_tick") Click to expand... were "mm" is the name of the module were the event sould fire The answer is......YES!!!!!! Last edited: Apr 24, 2010
Of course!!!!!!! I had forgot the AddEvent Keyword!!!!.... But can I use it this way? AddEvent("timer1", Tick, "mm.Timer1FromDifferentModule_tick") Click to expand... were "mm" is the name of the module were the event sould fire The answer is......YES!!!!!!