Link to home
Start Free TrialLog in
Avatar of shanko
shanko

asked on

Is there a PostEvent instead of RaiseEvent ?

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 ...
Avatar of JonFish85
JonFish85

Try this:

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


hope this helps!
The thing that you are thinking of is DoEvents, this allows VB to react to other events when in a processing loop.
ASKER CERTIFIED SOLUTION
Avatar of dnechodom
dnechodom

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I would go with the
Me.Show
DoEvents

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

Regards,
CJ
Avatar of shanko

ASKER

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 !
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.