Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can't get VFP-Form active in W2K
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Divers
Thread ID:
00546080
Message ID:
00547268
Vues:
14
Okay, for you as a persistent person (probably nothing better to do ...), here it is. Just run it on the VFP.EXE DE from the command window.
Please don't look at the variable-names.

Note : This is the normal version which should bring the VFP-window forward and which it already doesn't (W2K only), not to speak about having it active.
The version which puts all aother tasks to the taskbar, leaves you with the VFP-window brought forward, but again, not active.

Another version with an EnableWindow (one never knows ...) doesn't work too.
A DoEvents etc. here and there ... nada.

Cheers !
tim_w = seconds()

do while seconds()-tim_w < 6      && No, don’t use such loops anymore !

  *** Activate another task here (alt-tab etc). ***

enddo

=windtes2('Microsoft Visual FoxPro',.T.)
The above calls the below.
*** WINDTES2. ***

*** Look for window and activate. ***

PARAMETERS CAPTION_W, EXACT_W

IF (TYPE("CAPTION_W") <> "C") .OR. (TYPE("EXACT_W") <> "L")
   RETURN .F.
ENDIF

#DEFINE GW_HWNDNEXT     2
#DEFINE GW_CHILD        5
#DEFINE SW_RESTORE      9
#DEFINE SW_SHOW 	5

DECLARE INTEGER GetWindow IN USER32 INTEGER, INTEGER
DECLARE INTEGER GetDesktopWindow IN USER32
DECLARE INTEGER GetWindowText IN USER32 INTEGER, STRING @, INTEGER
DECLARE INTEGER IsIconic IN USER32 INTEGER
DECLARE INTEGER SetForegroundWindow IN USER32 INTEGER
DECLARE INTEGER ShowWindow IN USER32 INTEGER, INTEGER


RESULT_W = .F.                         && Succeeded ?

*** Start with the Desktop. ***

HWND_W = GetWindow(GetDesktopWindow(), GW_CHILD)

*** Loop through all Windows. ***

DO WHILE HWND_W > 0

   TITLE_W = REPLICATE(CHR(0), 128)
   TITLELEN_W = GetWindowText(HWND_W, @TITLE_W, 128)
   TITLELEN_W = MIN(TITLELEN_W, 128)
   TITLE_W = SUBSTR(TITLE_W, 1, TITLELEN_W)
   IF (.NOT. EMPTY(TITLE_W))

      *** Debug. ***
      ?TITLE_W      

      IF EXACT_W .AND. CAPTION_W = TITLE_W
         RESULT_W = .T.
         EXIT
      ENDIF

      IF (.NOT. EXACT_W) .AND. CAPTION_W $ TITLE_W
         RESULT_W = .T.
         EXIT
      ENDIF
   ENDIF
      
   *** Next... ***

   HWND_W = GetWindow(HWND_W, GW_HWNDNEXT)
   
ENDDO

IF RESULT_W                            && Found ?

   *** Activate. ***

   IF IsIconic(HWND_W) > 0
      =ShowWindow(HWND_W, SW_SHOW)     && Try SW_RESTORE here too.
      ??chr(7)
   ENDIF                       

   =SetForegroundWindow(HWND_W)
ENDIF

RETURN RESULT_W
>Hi!
>
>Hmm, if I can take a look to that program... Indeed, very strange problem.
>
>>Yo !
>>
>>All doesn't help;
>>
>>We even turned the ShowWindow the other way around : put all other windows to the taskbar. Doesn't help either.
>>
>>Let's forward this to Bill (or whoever is in charge there now).
>>
>>Thx for helping, but let's give up...
>>
>>
>>>Hi!
>>>
>>>Its quite strange, because you're talking about something that looks like a bug in W2K ;) Just set _VFP.AutoYield to .T., or issue DOEVENTS somewhere in your startup program after you issued ShowWindow(). When VFP app program in working, you cannot either minimize or maximize or whatever in VFP until VFP process these events. VFP proces them when _VFP.AutoYield is .T., or during the waiting state. DOEVENTS also allow to simulate waiting state by processing all pending events.
>>>
>>>Finally, under W2K clicking on the taskbar on the application icon will cause it to minimize. Look if you're not overused the ShowWindow function so it shows VFP 2 time by such way that it is minimized by taskbar (just a joke - this seems works only by mouse, but who know ;)
>>>
>>>HTH.
>>>
>>>>Back again, and the night will be darker as I expected ...
>>>>
>>>>We setup a small program that uses GetWindow, GetDesktopWindow, GetWindowText, IsIconic, SetForegroundWindow, ShowWindow. To get the idea.
>>>>The ShowWindow (IF IsIcon()) was performed with SW_SHOW and SW_RESTORE;
>>>>All is running fine in W95 (I expect - and the rest), but won't work in W2K;
>>>>The Iconized task remains like that, though it flikkers a 5 times dark-blue ("want to tell you something ...") and remains dark-blue after that.
>>>>So I guess there is a real problem here.
>>>>
>>>>BUT :
>>>>
>>>>By now I can narrow down the problem to VFP-W2K only, I mean, not being dependent on our app :
>>>>
>>>>Our testprogram runs standalone, and can be performed on the VFP-DE-desktop;
>>>>After the program is started, it waits for a few secs, and allows you to minimize VFP or make another task active (alt-tab etc.). Once the timer elapses, it makes VFP the active task again. Well, it does on W95, but doesn't on W2K. So ???
>>>>
>>>>So everyone should be dealing with this.
>>>>
>>>>Now note that if I start VFP-DE without app, nothing is the matter, and the problem WILL originate from starting other tasks like our app does. This of course to be prooven bij the test-program, which just should work but doesn't (and does on W95 !).
>>>>
>>>>Now coincidentally I saw PC-Anywhere behave the same (doesn't come forward after startup, but form is there at wrong ZOrder). Thus, a W2K problem I guess.
>>>>
>>>>Is anyone experienced on this anoying thing ?
>>>>
>>>>We can survive with it, but it bothers me.
>>>>Please don't bother writing this test-program, because I can put it here easily.
>>>>
>>>>
>>>>>Hi!
>>>>>
>>>>>If DECLARE DLL exists, that you will be able to use these API functions. It seems you just misunderstood what is API function here - it is not the FoxAPI function. It is Windows API function from Windows kernels and DLLs. Both ShowWindow, FindWindow and SetForegroundWindow are Windows API functions. There is a section here at UT for API functions where you can find a lot of samples. Take a look also to the Anatoliy Mogylevets site http://www.news2news.com/vfp/index.php that is also for using Windows API functions in VFP. With these functions you can do a lot more things...
>>>>>
>>>>>HTH.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform