Code Comments
Programming Forum and web based access to our favorite programming groups.List: I'm searching the helpfiles and not finding the information. I'm probably using the wrong terms. Anyway. When I display a form, what methods are invoked when? When I hide a form, same question. I'm chasing what seems to be a race condition, but what I suspect is really happening is that I don't fully understand what methods are being invoked when. Is there a difference between invoking a form from another method and using Me.Show? Thanks Charles
Post Follow-up to this messageU-CDK_CHARLES\Charles wrote: > List: > > I'm searching the helpfiles and not finding the information. I'm > probably using the wrong terms. > > Anyway. > > When I display a form, what methods are invoked when? The best way to find this kind of info is to create a new project and place a Debug.Print line in each of the forms events. Save that form in your Templates folder for future use. Here.... I have an addin that makes this kind of thing quick and easy... watch for word wrap before running.... comment out the events you don't want to see (most likely MouseMove cause you'll get "information overload") '============= Option Explicit Private Sub Form_Activate() Debug.Print "'Form1:Form_Activate", Timer End Sub Private Sub Form_Click() Debug.Print "'Form1:Form_Click", Timer End Sub Private Sub Form_DblClick() Debug.Print "'Form1:Form_DblClick", Timer End Sub Private Sub Form_Deactivate() Debug.Print "'Form1:Form_Deactivate", Timer End Sub Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single) Debug.Print "'Form1:Form_DragDrop", Timer End Sub Private Sub Form_DragOver(Source As Control, X As Single, Y As Single, State As Integer) Debug.Print "'Form1:Form_DragOver", Timer End Sub Private Sub Form_GotFocus() Debug.Print "'Form1:Form_GotFocus", Timer End Sub Private Sub Form_Initialize() Debug.Print "'Form1:Form_Initialize", Timer End Sub Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) Debug.Print "'Form1:Form_KeyDown", Timer End Sub Private Sub Form_KeyPress(KeyAscii As Integer) Debug.Print "'Form1:Form_KeyPress", Timer End Sub Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer) Debug.Print "'Form1:Form_KeyUp", Timer End Sub Private Sub Form_LinkClose() Debug.Print "'Form1:Form_LinkClose", Timer End Sub Private Sub Form_LinkError(LinkErr As Integer) Debug.Print "'Form1:Form_LinkError", Timer End Sub Private Sub Form_LinkExecute(CmdStr As String, Cancel As Integer) Debug.Print "'Form1:Form_LinkExecute", Timer End Sub Private Sub Form_LinkOpen(Cancel As Integer) Debug.Print "'Form1:Form_LinkOpen", Timer End Sub Private Sub Form_Load() Debug.Print "'Form1:Form_Load", Timer End Sub Private Sub Form_LostFocus() Debug.Print "'Form1:Form_LostFocus", Timer End Sub Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Debug.Print "'Form1:Form_MouseDown", Timer End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Debug.Print "'Form1:Form_MouseMove", Timer End Sub Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) Debug.Print "'Form1:Form_MouseUp", Timer End Sub Private Sub Form_OLECompleteDrag(Effect As Long) Debug.Print "'Form1:Form_OLECompleteDrag", Timer End Sub Private Sub Form_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single) Debug.Print "'Form1:Form_OLEDragDrop", Timer End Sub Private Sub Form_OLEDragOver(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single, State As Integer) Debug.Print "'Form1:Form_OLEDragOver", Timer End Sub Private Sub Form_OLEGiveFeedback(Effect As Long, DefaultCursors As Boolean) Debug.Print "'Form1:Form_OLEGiveFeedback", Timer End Sub Private Sub Form_OLESetData(Data As DataObject, DataFormat As Integer) Debug.Print "'Form1:Form_OLESetData", Timer End Sub Private Sub Form_OLEStartDrag(Data As DataObject, AllowedEffects As Long) Debug.Print "'Form1:Form_OLEStartDrag", Timer End Sub Private Sub Form_Paint() Debug.Print "'Form1:Form_Paint", Timer End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) Debug.Print "'Form1:Form_QueryUnload", Timer End Sub Private Sub Form_Resize() Debug.Print "'Form1:Form_Resize", Timer End Sub Private Sub Form_Terminate() Debug.Print "'Form1:Form_Terminate", Timer End Sub Private Sub Form_Unload(Cancel As Integer) Debug.Print "'Form1:Form_Unload", Timer End Sub '============= > When I hide a form, same question. You'll see when you run the code above. > I'm chasing what seems to be a race condition, but what I suspect is > really happening is that I don't fully understand what methods are being > invoked when. > > Is there a difference between invoking a form from another method and > using Me.Show? Not as far as the events are concerned. Try it with the code above. These may come in handy.... Differences Among Form's Initialize, Load, and Activate Events http://support.microsoft.com/defaul...kb;en-us;138819 Life Cycle of Visual Basic Forms http://msdn.microsoft.com/library/d...lbasicforms.asp btw... if you ever create a usercontrol, the Events template (you'll see it when adding a usercontrol to the project) is basically the Debug.Print stuff above in usercontrol events instead of form events. -- Ken Halter - MS-MVP-VB - http://www.vbsight.com Please keep all discussions in the groups..
Post Follow-up to this messageHey Charles, Main points for you to know are: - Me.Hide will not inherently trigger an event, it may trigger Form_Deactivate to fire if the form were active when Me.Hide ran but I'm not sure about this and it's not something you would want to rely on. - When you load a form the Form_Load event will run. Using Me.Show means that the form is already loaded, so Form_Load will not fire again, however i f you show the form from another form/module using FormName.Show, the Form_Loa d event will run. -When the form is unloaded (Unload Me, or Unload FormName when doing from another form) the Form_Unload event will run. -If you need certain actions to occur when showing or hiding a form that is already loaded, you could make a custom procedure that has a boolean argumen t (i.e. blnHide) and just call that procedure instead of using me.show or me.hide, passing the appropriate value to the procedure and then within the procedure, depending on the value of blnHide, either hide or show the form and run appropriate actions at the same time. Hope this helps, Brian H. "U-CDK_CHARLES\\Charles" <"Charles Krug" wrote: > List: > > I'm searching the helpfiles and not finding the information. I'm > probably using the wrong terms. > > Anyway. > > When I display a form, what methods are invoked when? > > When I hide a form, same question. > > I'm chasing what seems to be a race condition, but what I suspect is > really happening is that I don't fully understand what methods are being > invoked when. > > Is there a difference between invoking a form from another method and > using Me.Show? > > Thanks > > > Charles > >
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.