johncook,
Ok here's the code. It will open the On-Screen Keyboard application, get a reference to its window handle and then use that to move it to the bottom-center of your screen. I am also showing you how to use ShellExecute rather than the RUN command just for informational purposes. Cut-N-Paste the code below into a prg file and run it from within VFP.
#DEFINE SM_CXSCREEN 0
#DEFINE SM_CYSCREEN 1
LOCAL lnScrWidth, lnScrHeight, lnWinWidth, lnWinHeight
DO DeclareAPIs &&Need these functions
ShellExecute (0, "open", "osk", "", "", 0)
*!* RUN /N7 osk && This works too
=INKEY(2)
&&Give windows a moment to open it
lnhwnd = FindWindow (0, "On-Screen Keyboard"
GetWidthHeight(lnhwnd, @lnWinWidth, @lnWinHeight)
lnScrWidth = GetSystemMetrics(SM_CXSCREEN)
lnScrHeight = GetSystemMetrics(SM_CYSCREEN)
*!* Bottom Centered
MoveWindow (lnhwnd,;
(lnScrWidth-lnWinWidth)/2, lnScrHeight-lnWinHeight,;
lnWinWidth, lnWinHeight, 1)
*!* *!* Centered
*!* MoveWindow (lnhwnd,;
*!* (lnScrWidth-lnWinWidth)/2, (lnScrHeight-lnWinHeight)/2,;
*!* lnWinWidth, lnWinHeight, 1)
*!* *!* Upper Left
*!* MoveWindow (lnhwnd,;
*!* 0, 0,;
*!* lnWinWidth, lnWinHeight, 1)
***********************
PROCEDURE DeclareAPIs
***********************
DECLARE INTEGER ShellExecute IN shell32;
INTEGER hwnd, STRING lpOperation,;
STRING lpFile, STRING lpParameters,;
STRING lpDirectory, INTEGER nShowCmd
DECLARE INTEGER FindWindow IN user32;
STRING lpClassName, STRING lpWindowName
DECLARE INTEGER GetSystemMetrics IN user32 INTEGER nIndex
DECLARE INTEGER MoveWindow IN user32;
INTEGER HWND, INTEGER X, INTEGER Y,;
INTEGER nWidth, INTEGER nHeight, INTEGER bRepaint
DECLARE INTEGER GetWindowRect IN user32 INTEGER HWND, STRING @lpRect
ENDPROC
***********************
FUNCTION buf2int(cBuffer)
***********************
RETURN ASC(SUBSTR(cBuffer, 1,1)) + ;
BITLSHIFT(ASC(SUBSTR(cBuffer, 2,1)), 8) +;
BITLSHIFT(ASC(SUBSTR(cBuffer, 3,1)), 16) +;
BITLSHIFT(ASC(SUBSTR(cBuffer, 4,1)), 24)
ENDFUNC
***********************
PROCEDURE GetWidthHeight(phwnd, pWidth, pHeight)
***********************
LOCAL lpRect, lnWinLeft, lnWinTop, lnWinRight, lnWinBottom
lpRect = REPLI (CHR(0), 16)
GetWindowRect (phwnd, @lpRect)
lnWinLeft = buf2int(SUBSTR(lpRect, 1,4))
lnWinTop = buf2int(SUBSTR(lpRect, 5,4))
lnWinRight = buf2int(SUBSTR(lpRect, 9,4))
lnWinBottom = buf2int(SUBSTR(lpRect, 13,4))
pWidth = lnWinRight - lnWinLeft + 1
pHeight = lnWinBottom - lnWinTop + 1
ENDPROC
Slighthaze =
NULL
[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]