我是这么声明的:Declare Function SetWindowLong Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Integer, ByVal dwNewLong As Long) As Long
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
谢谢! 原来是 SetWindowLongA 啊
To pgfun()兄 :我在模块中定义: Public Function WWndProc(ByVal hw As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long MsgBox "hehe..." preWndProc = CallWindowProc(preWndProc, hw, Msg, wParam, lParam) End Function在窗体文件中定义: Private Sub Form_Load() preWndProc = SetWindowLong(Me.hWnd, GWL_WNDPROC, AddressOf WWndProc) End Sub可是,WWndProc根本就执行不到,这是怎么回事?
<<你是否在DLL中加入了Sendmessage函数发送消息。另外在Sendmessage中设定的接受消息的口局柄是否正确。 preWndProc = SetWindowLong(Me.hWnd, GWL_WNDPROC, AddressOf WWndProc) 这个函数的返回值为0,看来是SetWindowLong()的使用有问题。/*-------------------------------------------------*/ SetWindowLong The SetWindowLong function changes an attribute of the specified window. The function also sets a 32-bit (long) value at the specified offset into the extra window memory of a window. LONG SetWindowLong( HWND hWnd, // handle of window int nIndex, // offset of value to set LONG dwNewLong // new value ); Return Values If the function succeeds, the return value is the previous value of the specified 32-bit integer. If the function fails, the return value is zero. /*-------------------------------------------------*/
我是在Sub Main()执行呀!怎么还不行?我在模块中定义: Public Function WWndProc(ByVal hw As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long MsgBox "hehe..." preWndProc = CallWindowProc(preWndProc, hw, Msg, wParam, lParam) End Function在启动窗体中定义: Private Sub Form_Load() preWndProc = SetWindowLong(Me.hWnd, GWL_WNDPROC, AddressOf WWndProc) End Sub可是,WWndProc根本就执行不到。
Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long Private Declare Function SetMenuItemBitmaps Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal hBitmapUnchecked As Long, ByVal hBitmapChecked As Long) As Long Const myflag = &H400&
好像加上with event就行了。
你的声明好像有点问题,试试下面这个:) Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long 我的系统为Windows2000 Server 祝你好运*^_^*
Public Function WWndProc(ByVal hw As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long MsgBox "hehe..." WWndProc = CallWindowProc(preWndProc, hw, Msg, wParam, lParam) End Function
CallWindowProc(preWndProc, hw, Msg, wParam, lParam)
在VB里应该怎么声明呀,我怎么老是找不到dll的入口?
Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
原来是 SetWindowLongA 啊
Public Function WWndProc(ByVal hw As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
MsgBox "hehe..."
preWndProc = CallWindowProc(preWndProc, hw, Msg, wParam, lParam)
End Function在窗体文件中定义:
Private Sub Form_Load()
preWndProc = SetWindowLong(Me.hWnd, GWL_WNDPROC, AddressOf WWndProc)
End Sub可是,WWndProc根本就执行不到,这是怎么回事?
这个函数的返回值为0,看来是SetWindowLong()的使用有问题。/*-------------------------------------------------*/
SetWindowLong
The SetWindowLong function changes an attribute of the specified window. The function also sets a 32-bit (long) value at the specified offset into the extra window memory of a window. LONG SetWindowLong(
HWND hWnd, // handle of window
int nIndex, // offset of value to set
LONG dwNewLong // new value
);
Return Values
If the function succeeds, the return value is the previous value of the specified 32-bit integer.
If the function fails, the return value is zero.
/*-------------------------------------------------*/
Public Function WWndProc(ByVal hw As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
MsgBox "hehe..."
preWndProc = CallWindowProc(preWndProc, hw, Msg, wParam, lParam)
End Function在启动窗体中定义:
Private Sub Form_Load()
preWndProc = SetWindowLong(Me.hWnd, GWL_WNDPROC, AddressOf WWndProc)
End Sub可是,WWndProc根本就执行不到。
Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function SetMenuItemBitmaps Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal hBitmapUnchecked As Long, ByVal hBitmapChecked As Long) As Long
Const myflag = &H400&
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
我的系统为Windows2000 Server
祝你好运*^_^*
MsgBox "hehe..."
WWndProc = CallWindowProc(preWndProc, hw, Msg, wParam, lParam)
End Function