Solved

Excuting order

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

724 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