Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Fire an event in one VFP program from another VFP progra
Message
From
06/01/2003 01:30:58
Keith Payne
Technical Marketing Solutions
Florida, United States
 
 
To
03/01/2003 19:28:42
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00737929
Message ID:
00738308
Views:
23
>I have a button in FoxPro Task1 that launches FoxPro Task2 (separate executables). If the user returns to FoxPro Task1 while Task2 is waiting for events, and presses the button again, I want to "activate" Task2: that is, I want to bring Task2 to the top of the ZOrder and fire some event in Task2 (preferably the form's Activate event).
>
>I can use SetForegroundWindow() to bring the window to the top of the ZOrder, but no event is fired. Notably, if I use Alt-Tab to switch context between Task1 and Task2, no event fires in Task2. I suspect that if I solve the problem for Alt-Tab I will also have solved it for SetForegroundWindow().
>
>Is there a FoxPro event in the target window that fires when SetForegroundWindow() is executed? Alternatively, is there a way with VFP 7 that I can capture the apropriate Windows event?

Jack,

You can use Task2's MAIN window title to determine if it is still running.
Check FAQ #7957 to get a feel for identifying windows tasks (processes). There is a API function similar to GetWindowThreadProcessId that will give you the title of the window. You'll have to poke around in the MSDN Knowledgebase (http://msdn.microsoft.com) to find the exact function name.

In any case, you will not be able to intercept Alt-tab task switching inside your VFP application.

To answer the second part of your question, you could write a wrapper function for SetForegroundWindow() that fires a the Activate() event in the target form.
function MySetForegroundWindow(cFormName as String)

     local cCommand

     cCommand = cFormName+".Activate()"
     &cCommand

end function
A final note: Getting VFP to behave like a multi-threaded application is nearly an impossible task. I suggest re-analyzing your project to see if there is another way of accomplishing your goals without two separate tasks.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform