Hi!
DECLARE INTEGER FindWindow IN Win32API;
string lpClassName, STRING lpWindowName
and do not use '@' for second parameter. When you declare it the way you described, the reference to '0' will be used that is really is not a zero value (null pointer) ;) In addition, VFP passes strings by reference anyway. At least I use after such declaration ? FindWindow(0,_Screen.Caption) and it returns non-zero value. Note that in W2K it could return negative numbers, so just check for zero.
>Guess I could do with VFP7! I just can't get it to detect the window! Here is the code - I wondered if you could see any problems with it?
>
>DECLARE INTEGER FindWindow IN Win32API;
>STRING @lpClassName, ;
>STRING @lpWindowName
>
>lcApplicationTitle = (oApp.AppTitle + oApp.FormCaption)
>*!* wait window "Caption " + (lcApplicationTitle)
>lnHWnd = FindWindow(0, @lcApplicationTitle)
>
>*!* wait window "Handle " + str(lnHWnd)
>
>DECLARE SHORT SetForegroundWindow IN USER32.DLL INTEGER lnHWnd
>* I assume you've got the hWnd you want stored in the variable nhWnd
>IF SetForegroundWindow(lnHWnd) # 0
> * the desired window and thread are now in the foreground
>wait window "Success"
>ELSE
>wait window "Failed"
> * the hWnd was not assigned to the foreground and the thread
> * remains at its default priority
>ENDIF
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.comICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs
It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.