Solved

Is there a PostEvent instead of RaiseEvent ?

Posted on 2001-07-30
6
309 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
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 100 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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now