Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to set focus to exe
Message
From
17/03/2004 20:12:39
Charlie Hancock
California Dept of Public Health
Richmond, California, United States
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00886769
Message ID:
00887358
Views:
16
Thanks for the pointer, Sergey. I have not used Windows API calls before, and the various things I'm trying so far (snipped from the Windows API pages on Universal Thread) are not producing the desired result.

To reiterate the problem:

I'm calling a VFP 8.0 executable from within a FoxPro 2.6 application, using the command:

RUN /N1 Foo.exe

I want the called exe to act as much like a modal form as possible. The exe consists of a Main.prg and a single form. The Main.prg says:

Application.Visible = .F.
DO FORM Foo.scx
READ EVENTS

The form has these properties set:

AlwaysOnTop = .T.
ShowWindow = 2 && top-level form
WindowType = 1 && modal

I'm trying these Windows API statements in the form's .Init() code:

* Find my window handle:
lcApplicationTitle = THISFORM.Caption
DECLARE INTEGER FindWindow IN Win32API ;
STRING @lpClassName, ;
STRING @lpWindowName
lnHWnd = FindWindow(0, @lcApplicationTitle)

* Bring my window to the foreground (though my form properties
* already do that):
DECLARE SHORT SetForegroundWindow IN USER32.DLL INTEGER hWnd
SetForegroundWindow(lnHWnd)

* Try to make mine the active window (this may happen briefly,
* but focus goes right back to the FP 2.6 app):
DECLARE INTEGER SetActiveWindow IN USER32 INTEGER hWnd
SetActiveWindow(lnHWnd)


I've looked at the return values from the Windows API calls, and they seem to be valid (non-zero). Ideas, anyone?
Charlie Hancock
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform