|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to tell when form has fully loadedIs there an event that occurs when a VB form has fully loaded and displayed?
(like the onload event in javascript) Thanks If I had to guess, I would say the form's Activate event would tell you
that. Put this in the (General)(Declarations) section of the form's code window... Dim InitialLoad As Boolean Put this in the form's Load event... InitialLoad = "True" And use this code layout for the form's Activate event... Private Sub Form_Activate() If InitialLoad Then InitialLoad = False ' ' Put the code you want to run after the form ' loads and displays for the first time here. ' End If ' ' Put your regular Activate event code here ' End Sub I would think the above layout should do what you want. -- Show quoteHide quoteRick (MVP - Excel) "Giles" <gi***@noreply.com> wrote in message news:eDBCF7upJHA.4540@TK2MSFTNGP04.phx.gbl... > Is there an event that occurs when a VB form has fully loaded and > displayed? (like the onload event in javascript) > Thanks >
Show quote
Hide quote
"Rick Rothstein" <rick.newsNO.SPAM@NO.SPAMverizon.net> wrote: If you have a Show command in your form load code then the Activate event will fire before>If I had to guess, I would say the form's Activate event would tell you >that. Put this in the (General)(Declarations) section of the form's code >window... > > Dim InitialLoad As Boolean > >Put this in the form's Load event... > > InitialLoad = "True" > >And use this code layout for the form's Activate event... > > Private Sub Form_Activate() > If InitialLoad Then > InitialLoad = False > ' > ' Put the code you want to run after the form > ' loads and displays for the first time here. > ' > End If > ' > ' Put your regular Activate event code here > ' > End Sub > >I would think the above layout should do what you want. the rest of the form Load code is finished. -mhd "Giles" <gi***@noreply.com> wrote in message For some crazy reason, the Resize event does. I usually do something like news:eDBCF7upJHA.4540@TK2MSFTNGP04.phx.gbl... > Is there an event that occurs when a VB form has fully loaded and > displayed? this: Private Sub Form_Resize() Static fAlreadyDisplayed As Boolean If Not fAlreadyDisplayed Then ' Do all your first-time-the-form-was-displayed stuff here fAlreadyDisplayed = true End If End Sub
Show quote
Hide quote
"Jeff Johnson" <i.get@enough.spam> wrote in message I use that method too. It's documented in the help: "Resize Event: Occurs news:etaJmQxpJHA.5980@TK2MSFTNGP06.phx.gbl... > "Giles" <gi***@noreply.com> wrote in message > news:eDBCF7upJHA.4540@TK2MSFTNGP04.phx.gbl... > >> Is there an event that occurs when a VB form has fully loaded and >> displayed? > > For some crazy reason, the Resize event does. I usually do something like > this: > > Private Sub Form_Resize() > Static fAlreadyDisplayed As Boolean > > If Not fAlreadyDisplayed Then > ' Do all your first-time-the-form-was-displayed stuff here > > fAlreadyDisplayed = true > End If > End Sub when an object is first displayed or when the window state of an object changes." Nobody wrote:
Show quoteHide quote >>> Is there an event that occurs when a VB form has fully loaded and Yeah, but as 'mhd' pointed out, I don't think this is the answer to "fully loaded" >>> displayed? >> >> For some crazy reason, the Resize event does. I usually do something like >> this: >> >> Private Sub Form_Resize() >> Static fAlreadyDisplayed As Boolean >> >> If Not fAlreadyDisplayed Then >> ' Do all your first-time-the-form-was-displayed stuff here >> >> fAlreadyDisplayed = true >> End If >> End Sub > > I use that method too. It's documented in the help: "Resize Event: Occurs > when an object is first displayed or when the window state of an object > changes." either, in cases where a Me.Show is used in Form_Load. (Bad form, so to speak, IMO.) If you're going to do that, it's really up to you (generic "you") to trigger whatever you need to as the last line in Form_Load, because you have already futzed up the entire scheme of things. "Giles" <gi***@noreply.com> escribió en el mensaje de noticias No there isn't.news:eDBCF7upJHA.4540@TK2MSFTNGP04.phx.gbl... > Is there an event that occurs when a VB form has fully loaded and > displayed? (like the onload event in javascript) If the Form is explicitly shown and any routine calls 'DoEvents' before the 'Form_Load' ends, the Form will be fully loaded and displayed after the last sentence of the 'Form_Load' event. Otherwise it will be fully loaded and displayed at the first 'Form_Activate' notification: '***************** Public Event LoadComplete(ByVal CompletedOn As LoadCompleteConstants) Public Enum LoadCompleteConstants OnActivate OnLoad End Enum Private m_Loaded As Boolean Private m_Activated As Boolean Private Sub Form_Activate() If m_Activated = False Then If m_Loaded = True Then RaiseEvent LoadComplete(OnActivate) m_Activated = True End If ' '··· End Sub Private Sub Form_Load() '··· ' If m_Activated = True Then RaiseEvent LoadComplete(OnLoad) m_Loaded = True End Sub '***************** -- Regards - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ( ! ) http://groups.google.com/group/microsoft.public.vb.general.discussion ( i ) http://www.microsoft.com/communities/conduct/default.mspx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Value > Long Data Type
How to make this call from form to control Differences between VB amd VBA and VBA Education Application.Quit but Word remains open in Task Manager VB App fails when log reaches 65536 HOW IS Memory Used by a VB App vb.net executing on Internal String Visibility NET Required ??? Knowing what launched an EXE that used CreateProcess()? |
|||||||||||||||||||||||