• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 300
  • Last Modified:

Excuting order

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
username1
Asked:
username1
  • 3
  • 2
1 Solution
 
dwalexCommented:
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
 
username1Author Commented:
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
 
dwalexCommented:
By George, you're right. Sorry. Try the Paint event.
0
 
username1Author Commented:
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
 
dwalexCommented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now