DeclareFunctionSetWindowLongLib"User32"Alias"SetWindowLongA"(ByValhwndAsLong,ByValnIndexAsLong,ByValdwNewLongAsLong)AsLong
DeclareFunctionGetWindowLongLib"User32"Alias"GetWindowLongA"(ByValhwndAsLong,ByValnIndexAsLong)AsLong
DeclareFunctionCallWindowProcLib"User32"Alias"CallWindowProcA"(ByVallpPrevWndFuncAsLong,ByValhwndAsLong,ByValMsgAsLong,ByValwParamAsLong,ByVallParamAsLong)AsLong
DeclareFunctionRegisterHotKeyLib"User32"(ByValhwndAsLong,ByValidAsLong,ByValfsModifiersAsLong,ByValvkAsLong)AsLong
DeclareFunctionUnregisterHotKeyLib"User32"(ByValhwndAsLong,ByValidAsLong)AsLong
PublicFunctionWndproc(ByValhwndAsLong,ByValMsgAsLong,ByValwParamAsLong,ByVallParamAsLong)AsLong
"記錄原來的window程式地址
preWinProc=GetWindowLong(Me.hwnd,GWL_WNDPROC)
"用自定義程式代替原來的window程式
ret=SetWindowLong(Me.hwnd,GWL_WNDPROC,AddressOfWndproc)
RegisterHotKey(Me.hwnd,1,0,vbKeyF9)
ret=SetWindowLong(Me.hwnd,GWL_WNDPROC,preWinProc)
CallUnregisterHotKey(Me.hwnd,vbKeyF9)
DeclareFunctionSetWindowLongLib"User32"Alias"SetWindowLongA"(ByValhwndAsLong,ByValnIndexAsLong,ByValdwNewLongAsLong)AsLong
DeclareFunctionGetWindowLongLib"User32"Alias"GetWindowLongA"(ByValhwndAsLong,ByValnIndexAsLong)AsLong
DeclareFunctionCallWindowProcLib"User32"Alias"CallWindowProcA"(ByVallpPrevWndFuncAsLong,ByValhwndAsLong,ByValMsgAsLong,ByValwParamAsLong,ByVallParamAsLong)AsLong
DeclareFunctionRegisterHotKeyLib"User32"(ByValhwndAsLong,ByValidAsLong,ByValfsModifiersAsLong,ByValvkAsLong)AsLong
DeclareFunctionUnregisterHotKeyLib"User32"(ByValhwndAsLong,ByValidAsLong)AsLong
PublicFunctionWndproc(ByValhwndAsLong,ByValMsgAsLong,ByValwParamAsLong,ByVallParamAsLong)AsLong
"記錄原來的window程式地址
preWinProc=GetWindowLong(Me.hwnd,GWL_WNDPROC)
"用自定義程式代替原來的window程式
ret=SetWindowLong(Me.hwnd,GWL_WNDPROC,AddressOfWndproc)
RegisterHotKey(Me.hwnd,1,0,vbKeyF9)
ret=SetWindowLong(Me.hwnd,GWL_WNDPROC,preWinProc)
CallUnregisterHotKey(Me.hwnd,vbKeyF9)