Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
FindWindow and SetForegroundWindow in W98
Message
 
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00255586
Message ID:
00255641
Views:
23
Rick,

You might try using SetWindowPos() instead.
* HelpOnTop.prg 05-Jan-99

* Set the VFP6 help window to always ontop

* Usage: HelpOnTop( lOnTop )
* lOnTop - .t. set it to top
*          .f. set it to not on top

lparameter plOnTop

if ( ( type( "plOnTop" ) != "L" ) or ( pcount() = 0 ) )
   plOnTop = .t.
endif

local lnHwnd

#DEFINE HWND_TOPMOST -1
#DEFINE HWND_NOTOPMOST -2
#DEFINE SWP_NOSIZE 1
#DEFINE SWP_NOMOVE 2

declare integer FindWindow in win32api ;
  string lpClassName, ; && pointer to class name
  string lpWindowName   && pointer to window name

declare integer SetWindowPos IN win32api ;
  integer hWnd,            ; && handle to window
  integer hWndInsertAfter, ; && placement-order handle
  integer X,               ; && horizontal position
  integer Y,               ; && vertical position  
  integer cx,              ; && width
  integer cy,              ; && height
  integer uFlags             && window-positioning flags
  
lnHwnd = FindWindow( .null., "Visual FoxPro 6.0" )

if ( lnHwnd > 0 )
   SetWindowPos( lnHwnd, iif( plOnTop, HWND_TOPMOST, HWND_NOTOPMOST ), 0,0,0,0, SWP_NOSIZE + SWP_NOMOVE )
endif
>I am trying to use a combination of FindWindow() and SetForeground Window().
>
>
>DECLARE INTEGER FindWindow IN WIN32API ;
>        STRING  windowtype, ;
>        STRING  caption
>
>DECLARE INTEGER SetForegroundWindow IN WIN32API ;
>        INTEGER hwnd
>
>x = FindWindow(0,ALLTRIM(goMyForm.Caption))
>IF x#0
>   z=SetForegroundWindow(x)
>ELSE
>   messagebox("Not found/")
>ENDIF
>
>
>Under Windows95 this works, but under Windows98 and nt4sp4, the first time I use this code, it does not bring the window forward.
>
>Note: The ELSE is not executing, so I assume that FindWindow is getting a valid value.
>
>1. Am I calling this wrong?
>2. Is there a new version of the function in 98 and nt
>3. any suggestions.
>
>TIA,
>Rick
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform