Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do you get the window handle for _Screen
Message
From
15/11/2001 21:38:46
 
 
To
15/11/2001 18:19:00
Tom Kreinbring
Thomas Kreinbring & Associates
Temple City, California, United States
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00582452
Message ID:
00582512
Views:
23
>I have an application that starts another task doing a Run /N xxx.exe. The problem I am having is the new task keeps focus while
>the original task seems to run in the background. What I want to do is cause the original task to be the active task as quickly
>as possible after the second task is started. I have a routine that I have tried using the sendmessage command along with a
>messagereceived event. I coded a setfocus in the event but that did not work. A C programmer friend of mine said to try the
>windows setfocus command but in order to do that I need to know what my window handle is. Any ideas?

Rather than using RUN, use my API_APPRUN class; it will return a thread id and thread handle for the new application, and allow you to run it either synchronously or asynchronously, and determine when it terminates. If you have a thread handle, you can issue a Windows message to the main window of the new process via PostMessageToThread(), using the thread ID to specify the target of the message, which it then routes to it's primary hWnd. It also lets you specify the startup Window mode for the new executable.

You'd do something like:
SET CLASSLIB TO Process ADDITIVE
oAPP = CREATEONJ('API_APPRUN','MyExeToRun with parameters','C:\MyApp\ShouldRunHere','MAX')
*
*  You'd need to alter the class code not to release inThreadHandle, and add a method to return it
*
oApp.LaunchApp()
nMyAppThreadID = oApp.GetThreadId()
DECLARE SHORT PostThreadMessage IN USER32 ;
   INTEGER idThread, ;
   INTEGER Msg, ;
   INTEGER wParam, ;
   INTEGER lParam
DECLARE INTEGER GetActiveWindow IN WIN32API
=PostThreadMessage(nMyAppThreadID, WM_SHOWWINDOW, WA_ACTIVATE, GetActiveWindow())
You'll need to look up the values of WM_ACTIVATE and WA_ACTIVE in the MSDN docs or WINUSER.H
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform