Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP Apps Always takes Focus - Can this be changed?
Message
From
25/04/2008 10:45:13
 
 
To
24/04/2008 15:53:43
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows NT
Database:
MS SQL Server
Miscellaneous
Thread ID:
01312973
Message ID:
01313127
Views:
28
Try something like:
STORE ADLLS(dllArray) TO lnNumDLLs
IF ASCAN(dllArray,"GetActiveWindow") = 0
      DECLARE INTEGER GetActiveWindow IN User32 INTEGER
ENDIF
IF ASCAN(dllArray,"SetForegroundWindow") = 0
      DECLARE INTEGER SetForegroundWindow IN User32 INTEGER
ENDIF
 
*--Get the current calling program's window
IF TYPE('gnMainFoxWin') <> "N" .or. gnMainFoxWin = 0
      gnMainFoxWin=GetActiveWindow()
ENDIF
 
*--Run your prg that shifts focus
*--Note you might need a doevents after or a method of waiting for the focus
*--to shift so you can bring it back (don't call setforegroundwindow too 
*--soon)
*--Experiment with a DOEVENTS FORCE force here if you run into problems
*--but try it first without it
 
*--Bring focus back to the calling program
IF TYPE('gnFoxMainWin') = "N" AND gnFoxMainWin <> 0
      =SetForegroundWindow(gnMainFoxWin)            
ENDIF
DOEVENTS FORCE
>I have created many PRGS that have no interface and do not appear on taskbar nor show up on the normal desktop screen. I've accomplished this by adding the SCREEN=OFF statement to the config.fpw file. Also, I have found that I can include some occasional "WAIT WINDOW" statements in the program and only "wait window messages" appears on my desktop in the upper right corner of the screen. These messages go away after the TIMEOUT expires. This works really great, as it lets me know that the program is still running and I can tell from the messages where the program is, as it works though its tasks.
>
>In some ways, this is very similar to the "pop-up toast" messages that appear from Outlook, except these messages are at the top of the screen and they don't "fade" in and out. However, I've experienced one problem. These PRGs are launched via scheduler several times throughout the day and every time the PRGs launch it grabs focus from the current application I'm using (i.e., Outlook, Word, Excel, etc.). Focus can be returned to the application I'm using with just a mouse click but it's very annoying to be typing away and look up and see that nothing is happening because the application has just lost focus.
>
>FYI ... I read some articles on how to do the “pop-up toast" windows in VFP and tried my hand at creating these type of messages. It worked well but I had the same problem of program "grabbing" focus away from the current app whenever the VFP app launches. Now, once the application is running either the “WAIT WINDOW” approach or the “toast” window approach allows messages to come and go without intrusion on the user. But, when the program launches, that is when I loose focus!
>
>Is there any way to launch a VFP9 application in the "background" without it grabbing focus from the current app that has focus?
>
>Sorry for the length of this question but I didn't know how to word it any shorter.
>
>Thanks,
>Robert Wright
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform