SpQueryFocus: Difference between revisions
Appearance
m Martini moved page OS2 API:spQueryFocus to OS2 API:SPUTILS:spQueryFocus |
mNo edit summary |
||
| Line 39: | Line 39: | ||
CALL spSetPointerPos xptrpos,yptrpos | CALL spSetPointerPos xptrpos,yptrpos | ||
[[Category: | [[Category:SpUtils]] | ||
Revision as of 19:15, 26 February 2017
This function returns the focus window. It is NULLHANDLE if there is no focus window.
Syntax: hwnd = spQueryFocus ( [ hwndDesktop ] )
Parameter: hwndDesktop – Desktop-window handle. If ommited the default desktop handle (HWND_DESKTOP) will be used.
Returns:
0 – Error occurred or no focus window. >0 – Handle of the focus window.
Example Code:
/* scclock.cmd (spUtils Example Code) */
/* Switches the Smartcenter (aka WarpCenter or eComCenter) clock by */
/* simulating a button click on the clock */
CALL RXFUNCADD 'spLoadFuncs','spUtils','spLoadFuncs'
CALL spLoadFuncs
CALL spSetAutoSleep 0
focus=spQueryFocus()
PARSE VALUE spQueryPointerPos() WITH xptrpos yptrpos
hwnd=spFindWindowHandle(,,,'SmartCenter',,'\PMSHELL.EXE')
IF hwnd=0 THEN DO
SAY 'Smartcenter (WarpCenter or eComCenter) not found'
RETURN
END
xoffset=spQueryWindowPos(hwnd,'x')
yoffset=spQueryWindowPos(hwnd,'y')
xpos=spQueryWindowPos(hwnd,'cx')-5
ypos=5
CALL spSetPointerPos xoffset+xpos,yoffset+ypos
CALL spPostMsg hwnd,'WM_BUTTON1DOWN',spMPFROM2SHORT(xpos,ypos)
CALL spPostMsg hwnd,'WM_BUTTON1UP',spMPFROM2SHORT(xpos,ypos)
CALL spPostMsg focus,'WM_BUTTON1DOWN',spMPFROM2SHORT(0,0)
CALL spPostMsg focus,'WM_BUTTON1UP',spMPFROM2SHORT(0,0)
CALL spSetPointerPos xptrpos,yptrpos