I've observed with c++/non VB apps that when they are doing some CPU intensive work they run quite fast and still respond to user events like mouse-click, keypress etc.
Obviously they are not using any thing like the DoEvents of VB which processes the system message queue. Instead they seem to be giving time to only their own events.
In VB, the only way I know to let your app respond to events is to put a DoEvents in your procedure/loop.
Let's take a very simple example:
VB Code:
Option Explicit Dim bCancel As Boolean Private Sub cmdCancel_Click() If vbYes = MsgBox("Cancel Processing?", vbYesNo + vbQuestion) Then bCancel = True End If End Sub Private Sub cmdOK_Click() bCancel = False Do If bCancel Then Exit Do DoSomething DoEvents Loop MsgBox "OK", vbInformation End Sub Private Sub DoSomething() 'Add code to do something here End Sub
This code would work fine, but it is very slow. But if you comment out the Doevents, it would go very fast as it won't process the system message queue. But then it won't respond to cmdCancel_Click and you would ultimately have to End task teh application.
I was looking for some replacement for the DoEvents which won't process the entire system message queue, instead give time to my application only.
Pradeep![]()




icon on the left of the post.
Reply With Quote