6楼 的代码可以在 win7旗舰版 32位 + VFP 9 sp2 下运行。
如果是 64 位的 OS,这么做试试看:
DECLARE INTEGER ShellExecute IN shell32 INTEGER hWindow, STRING lpOperation, STRING lpFile, STRING lpParameters, STRING lpDirectory, INTEGER nShowCmd
DECLARE integer Wow64DisableWow64FsRedirection IN kernel32 Long @
DECLARE integer Wow64RevertWow64FsRedirection IN kernel32 Long @
DECLARE INTEGER SetParent IN User32 INTEGER HWND, INTEGER ParenthWnd
DECLARE INTEGER FindWindow IN user32 STRING lpClassName, STRING lpWindowName
DECLARE INTEGER GetWindowLong IN user32 INTEGER hWnd, INTEGER nIndex
DECLARE INTEGER SetWindowLong IN user32 INTEGER hWnd, INTEGER nIndex, INTEGER dwNewLong
DECLARE INTEGER GetLastError IN kernel32
CLEAR
PUBLIC ofrm
ofrm = CREATEOBJECT("MyForm")
ofrm.show()
DEFINE CLASS MyForm as Form
width = 1000
ShowWindow = 2
desktop = .T.
ADD OBJECT txt as textbox
ADD OBJECT cmd as commandbutton WITH top = 50 , caption = "\Click"
ADD OBJECT tmr as timer WITH interval = 200
PROCEDURE load
LOCAL lnVal
IF LEN(GETENV("ProgramFiles(x86)"))>1
xxx=Wow64DisableWow64FsRedirection(lnVal)
ENDIF
= ShellExecute(0, "open", "osk.exe", "", "", 1)
IF LEN(GETENV("ProgramFiles(x86)"))>1
xxx=Wow64RevertWow64FsRedirection(lnVal)
ENDIF
ENDPROC
PROCEDURE tmr.timer
* hOsk = FindWindow (.NULL., "On-Screen Keyboard")
hOsk = FindWindow (.NULL., "屏幕键盘")
nStyle = GetWindowLong (hOsk, -16)
This.Enabled = .F.
ACTIVATE SCREEN
?nStyle && 0x16CE0000
,BITSET(nStyle,30)
*- 0x80000000
?SetWindowLong (hOsk, -16, nStyle-0xCE0000) && tried to remove the title bar
?GetLastError() && Error 5 : ERROR_ACCESS_DENIED
?SetWindowLong (hOsk, -16, BITSET(nStyle,30)) && tried to set child
?GetLastError() && Error 5 : ERROR_ACCESS_DENIED
?SetWindowLong (hOsk, -16, nStyle+0x40000000) && tried to set child
?GetLastError() && Error 5 : ERROR_ACCESS_DENIED
?SetParent(hOsk, ThisForm.HWnd) && tried to change parent
?GetLastError() && Error 5 : ERROR_ACCESS_DENIED
ENDPROC
ENDDEFINE