// 適用於Windows 2K/XP/2003
// 所需 Windows API
Function Long SetForegroundWindow (Long Hwnd) Library "user32.dll" Alias For "SetForegroundWindow"
FUNCTION Long GetForegroundWindow() LIBRARY "user32.dll"
FUNCTION Long GetWindowThreadProcessId(long hwnd, ref Long lpdwProcessId) LIBRARY "user32.dll"
FUNCTION Long AttachThreadInput(long idAttach,long idAttachTo,long fAttach) LIBRARY "user32.dll"
long lProcessId, lCurID, lForeID, lHandle, lHandle2
lHandle = GetForegroundWindow () // 目前視窗焦點所在 handle
lHandle2 = Handle(this) // 自己的 handle
// 焦點不是自己
if lHandle <> lHandle2 then
lCurID = GetWindowThreadProcessId (lHandle, lProcessId)
lForeID = GetWindowThreadProcessId (lHandle2, lProcessId)
// 焦點設為自己
AttachThreadInput (lCurID, lForeID, 1)
SetForegroundWindow (lHandle2)
AttachThreadInput (lCurID, lForeID, 0)
end if
目前分類:Power Builder (1)
- Mar 14 Wed 2007 23:30
強迫取得視窗焦點。