用SetForegroundWindow()线程间切换前台窗口、AttachThreadInput()切换键盘输入焦点。
DECLARE LONG SetForegroundWindow IN user32 LONG
DECLARE LONG GetForegroundWindow IN user32
DECLARE LONG GetCurrentThreadId IN kernel32
DECLARE LONG GetWindowThreadProcessId IN user32 LONG, LONG
DECLARE LONG AttachThreadInput IN user32 LONG, LONG, LONG
DECLARE LONG ShowWindow IN user32 LONG, LONG
** Timer1.Timer
hForeWnd = GetForegroundWindow()
IF hForeWnd != thisform.hWnd
dwCurID = GetCurrentThreadId()
dwForeID = GetWindowThreadProcessId(hForeWnd, 0)
AttachThreadInput(dwCurID, dwForeID, .T.)
ShowWindow(thisform.hWnd, 1)
SetForegroundWindow(thisform.hWnd)
AttachThreadInput(dwCurID, dwForeID, .F.)
ENDIF
[ 本帖最后由 吹水佬 于 2014-6-29 22:24 编辑 ]
DECLARE LONG SetForegroundWindow IN user32 LONG
DECLARE LONG GetForegroundWindow IN user32
DECLARE LONG GetCurrentThreadId IN kernel32
DECLARE LONG GetWindowThreadProcessId IN user32 LONG, LONG
DECLARE LONG AttachThreadInput IN user32 LONG, LONG, LONG
DECLARE LONG ShowWindow IN user32 LONG, LONG
** Timer1.Timer
hForeWnd = GetForegroundWindow()
IF hForeWnd != thisform.hWnd
dwCurID = GetCurrentThreadId()
dwForeID = GetWindowThreadProcessId(hForeWnd, 0)
AttachThreadInput(dwCurID, dwForeID, .T.)
ShowWindow(thisform.hWnd, 1)
SetForegroundWindow(thisform.hWnd)
AttachThreadInput(dwCurID, dwForeID, .F.)
ENDIF
[ 本帖最后由 吹水佬 于 2014-6-29 22:24 编辑 ]