?
Solved

Is there a PostEvent instead of RaiseEvent ?

Posted on 2001-07-30
6
Medium Priority
?
345 Views
Last Modified: 2007-12-19
Is there a way (in VB 6.0) to "Post" an event to a form instead of "raising" it (with RaiseEvent) ? I am trying to initialize some objects in the load event of a window but it may take a while to do so. I want the window to show up immediately and then spin its wheels (show the hourglass etc.) while initializing. I thought raisevent would do the trick but it executes before the load event. I want something that executes after ...
0
Comment
Question by:shanko
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 6

Expert Comment

by:JonFish85
ID: 6336062
Try this:

Private Sub Form_Load()
  Me.Show
  'Other code here
End Sub


hope this helps!
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6336079
The thing that you are thinking of is DoEvents, this allows VB to react to other events when in a processing loop.
0
 

Accepted Solution

by:
dnechodom earned 400 total points
ID: 6336095
I use one of two techniques, depending on the method used to start the form's display. If the form is the startup form (as set in the project's properties), I use a static boolean in the Form_Activate method to allow execution as soon as the form is visible.

Private Sub Form_Activate()
    Static bLoaded As Boolean
... Other variable declarations
    If bLoaded Then Exit Sub
    bLoaded = True
... Code for initial display
    DoEvents        'Allows display to refresh
... Other initialization
End Sub

The other case is used when the application loads the form explicitly by calling a public method in the form module.

Public Sub ShowForm()
... Do things that must be done before form shows
    Me.Show         'Fires Form_Load
    DoEvents
... Do remaining initialization things
End Sub
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 22

Expert Comment

by:CJ_S
ID: 6336845
I would go with the
Me.Show
DoEvents

But the exact answer to your question is the API function PostMessage.

Regards,
CJ
0
 

Author Comment

by:shanko
ID: 6338689
thanks dnechodom, i have accepted your answer. I needed both the cases and your solution worked.

One minor irritation with the first case though: in Form_Activate event if I did:

Me.mousepointer = vbHourGlass

before the initialization, the mousepointer did not want to change to hourglass. Any idea why ?

thanks all, for pointing in the right direction !
0
 

Expert Comment

by:dnechodom
ID: 6340522
Glad to have helped out. Regarding the MousePointer issue, I've seen cases where the pointer is explicitly set by the control underneath it, overriding the "Me." pointer. If, at this time, your application begins an operation that takes a long time; i.e. a synchronous database query, the pointer will not change. Some of those cases cas include the change to the pointer when over a textbox or at the edge of the window. You might try changing the pointer in the Form_Load event, followed by a DoEvents.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question