Solved

Is there a PostEvent instead of RaiseEvent ?

Posted on 2001-07-30
6
338 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 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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…

728 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