Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Is there a PostEvent instead of RaiseEvent ?

Posted on 2001-07-30
6
Medium Priority
?
353 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

610 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