Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ShowWindow
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Titre:
Divers
Thread ID:
00278675
Message ID:
00280437
Vues:
13
Rick,

Thanks for reminding me/us about those other OSes.

>Here is another gotcha from the VC++ help file concerning SetForegroundWindow:
>
>The foreground window is the window at the top of the Z order. It is the window that the user is working with. In a preemptive multitasking environment, you should generally let the user control which window is the foreground window.
>
>Windows NT 5.0 and later: An application cannot force a window to the foreground while the user is working with another window. Instead, SetForegroundWindow will activate the window (see SetActiveWindow) and call theFlashWindowEx function to notify the user.

>
>Windows 98 falls into this category.
>
>What this means is that the window wont come forward, it will just flash on the taskbar.
>
>I ran into this recently and here is how a C++ programmer helped me solve it. I believe this centers on a locking timeout that forces the window to blink on the taskbar instead of coming forward. The trick is setting this timeout to 0, which prevents the flash and makes the window visible. The code below reads the current timeout, sets the timeout to 0, calls SetForegroundWindow, and then resets the timeout. I am sure that George correct me if I am wrong.
>
>
>
>IF glWindows98orWindows2000
>lnHWND = FindWindow(0,"My Form's Caption")
>DECLARE INTEGER SystemParametersInfo IN WIN32API INTEGER nAction, ;
>                                                 INTEGER nParam, ;
>                                                 INTEGER nvParam, ;
>                                                 INTEGER nfWini
>LOCAL timeout
>timeout=0
>#DEFINE SPI_GETFOREGROUNDLOCKTIMEOUT 0x2000
>#DEFINE SPI_SETFOREGROUNDLOCKTIMEOUT 0x2001
>#DEFINE SPIF_SENDCHANGE 0x0002
>
>SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT,0,@timeout,0)
>SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT,0,0,SPIF_SENDCHANGE)
>z=SetForegroundWindow(lnHWND)
>SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT,0,@timeout,SPIF_SENDCHANGE)
>
>
>
>Rick Hodder
>
>
>>David,
>>
>>Thanks for the reply. Both Ed and George's suggestion worked(Thanks). I am always trying to understand more...
>>
>>Are you passing something back to the orignal copy of the app to trigger the code below or is it in the second copy?
>>
>>What does the line external procedure mainhwnd do?
>>
>>Thanks
>>
>>>John,
>>>
>>>Here's what I use to bring the VFP app back on top if they try to launch another instance of the app:
>>>
>>>
if ( this.mlBringBackOnTop )
>>>
>>>   external procedure mainhwnd
>>>   SET LIBRARY TO "FOXTOOLS.FLL" additive
>>>   local lnHWND
>>>   lnHWND = mainhwnd()
>>>
>>>   if ( _screen.WindowState = 1 )
>>>      * this window is iconized so first we need to restore it
>>>
>>>      * Use the ShowWindow API call because we don't know whether to set WindowState to 0 or 2
>>>      * the API call does return the window to whatever state it was before it was iconized
>>>
>>>      declare integer ShowWindow in WIN32API integer, integer
>>>      #define SW_RESTORE 9
>>>
>>>      ShowWindow( lnHWND, SW_RESTORE )
>>>   endif
>>>
>>>   DECLARE INTEGER SetForegroundWindow IN WIN32API INTEGER
>>>
>>>   SetForegroundWindow( lnHWND )
>>>endif
>>>
>>>
>>>>I am using WIN32API to find out if the application is all ready loaded then using ShowWindow to show the window. I get inconsistant results on showing the window. Sometimes it is shown and sometimes it is only partialy painted. I have tried the following with 3, 5 and 6:
>>>>
>>>>

>>>>LPARAMETER lnHWND
>>>>
>>>>DECLARE INTEGER ShowWindow IN Win32API;
>>>> INTEGER hwnd, INTEGER dflag
>>>>
>>>>= ShowWindow(lnHWND, 3)
>>>>
>>>><\PRE>
>>>>
>>>>Does anyone know the syntax for ShowWindow to maximize the window and bring it to the top?
>>>>
>>>>Thanks
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform