Solved

Excuting order

Posted on 1998-11-07
5
295 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
[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
  • 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

738 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