Solved

Excuting order

Posted on 1998-11-07
5
291 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

920 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

18 Experts available now in Live!

Get 1:1 Help Now