Solved

Is there a PostEvent instead of RaiseEvent ?

Posted on 2001-07-30
6
327 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…
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…

830 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