Oops. I corrected the > 0, but it doesn't help.
About the HWND : must be right, since it works in W95 (explicitly activates the VFP-window.
It is tested on VFP5 and VFP6, and not VFP7; VFP7 probably needs some adjustments (just look at the Caption of the (are there more ??) active window and replace this in the line
=windtes2('Microsoft Visual FoxPro',.T.)
Any process ? well, if W2K supplies such a process, yes it can. But look at the test-program, and then where this process would come in. I can't guess.
>Woah!
>
>Because unusual method of searching for application, I would ask you - are you sure aboyt the HWND that you found? Are you sure that it is correct VFP main Screen window?
>
>Also, what VFP version you use? If it is VFP7, it contains 2 or more windows for main screen.
>
>Finally, are you sure there are no ANY process during that that can cause the main VFP window deactivate again?
>
>He-he, I also found a bug:
>
>DO WHILE HWND_W > 0
>
>Is not correct, because W2K can return negative integer number as window handle. I can bet here is a problem why it works in W98 and does not under W2K ;)
>
>HTH.
>
>>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
>>
>> *** 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.
>>
>>*** 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
>>
>> *** Activate. ***
>>
>> IF IsIconic(HWND_W) > 0
>> =ShowWindow(HWND_W, SW_SHOW)
>> ??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...
>>>>
>>>>