Solved

Excuting order

Posted on 1998-11-07
5
290 Views
Last Modified: 2010-04-30
In the following code, I set capture to a commend button and then call a help file by WinHelp function. I have found that after close the help file, the button losts the capture. So, I did SetCapture again.

Problem: the executing order is not as the order in the code! Perhaps it took long time to load the help file, the computer system just excuted the second SetCapture before calling WinHelp. I inserted DoEvents, but it didn't work at all. Infact the Capture of the button was lost again.

How can I get back the Capture?

SetCapture Command1.hwnd
WinHelp form1.hwnd, "Help.hlp", &H3, 0
DoEvents
SetCapture Command1.hwnd

I tried to replace DoEvents with MsgBox "...". In run time, I clicked OK in the MsgBox and got back the Capture. However, nobody like such a way.

Any suggestion?
0
Comment
Question by:username1
  • 3
  • 2
5 Comments
 
LVL 1

Expert Comment

by:dwalex
ID: 1443767
One alternative (there are no doubt others): Set an indicator in the form just before the call to WinHelp...

bGoneToHelp = True  

At that point, the focus goes off to HELP. When the focus returns to the form, the Activate event fires. Check the indicator, and if it's set, reset it, and then issue your SetCapture.

Form1.Activate
    if bGoneToHelp = true then
        bGoneToHelp = False
        SetCapture
    end if
0
 

Author Comment

by:username1
ID: 1443768
Hi dwalex,

I have just tested what you suggested but the event Activate couldn't fire after I close the help file (the focus returns to the form)! I have also tried GotFocus evnet for the form and got no success :-(

I am going to reopen this question. You are well come to re-answer or put any comment.

Cheers.
0
 
LVL 1

Accepted Solution

by:
dwalex earned 70 total points
ID: 1443769
By George, you're right. Sorry. Try the Paint event.
0
 

Author Comment

by:username1
ID: 1443770
I will try.

However, if the help window not cover the form (In my case, the form is quite small and actualy, I don't want the help window covers the form) the Paint event will not be fired.
0
 
LVL 1

Expert Comment

by:dwalex
ID: 1443771
Does the focus leave the command button if the form doesn't see the Paint event? Is there a need for your logic if the form isn't obscured?
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

759 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

19 Experts available now in Live!

Get 1:1 Help Now