请问这个函数怎么写呢?
SkinSE_SetMsgCallbackFunction--------------------------------------------------------------------------------
SkinSE_SetMsgCallbackFunction: 设置控件给其父窗口发生的消息响应的回调函数
BOOL SkinSE_SetMsgCallbackFunction(
LONG callbackFunction);
参数
callbackFunction
设置的回调函数的地址
返回值
如果函数调用成功返回非空;否则,返回空
备注
(1)如果没有设置回调函数,只能添加所需消息的响应函数,在MFC/WTL中通过消息映射来响应,其它计算机语言中需要重新设置窗口过程函数来设置
(2)回调函数在VC++中的实例:static LRESULT CallBackDirectUIHandler(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
参数说明:
HWND hwnd:发生消息的控件句柄
UINT uMsg:消息值,WM_DIRECTUI_CLICK or WM_DIRECTUI_DRAWITEM_CLICK,详细请查看帮助文档"DirectUI元素容器"
WPARAM wParam:消息响应参数
LPARAM lParam详细响应参数
实在搞不懂了,请用过的朋友指点下。
看lZ提出这样的问题,估计用起来也是很悬,系统崩溃是在所难免,前,记得要先保存
你的要求就是如下
BOOL SkinSE_SetMsgCallbackFunction( LONG callbackFunction);
该函数应该是用于设置回调函数,但应该使用了模块变量hWnd(函数关联的窗口句柄),将其加入到函数中吧
bas模块代码:
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
dim pPrevProc as long
public function SkinSE_SetMsgCallbackFunction(hWnd as long,callbackFunction as long) as long'callbackFunction =0可以恢复原来窗口参数
Public 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
if callbackFunction =0 then
if pPrevProc<>0 then
hPrev=setwindowlong(hwnd,-4, pPrevProc)
pPrevProc=0
end if
else
hPrev=setwindowlong(hwnd,-4, callbackFunction )
end function
private function CallBackDirectUIHandler(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) as long
select case umsg
csse WM_DIRECTUI_CLICK or WM_DIRECTUI_DRAWITEM_CLICK
'做出你的处理
case ........'其它你要处理的消息
case ........
end select
CallBackDirectUIHandler=CallWindowProc(pPrevProc,hwnd,msg,lParam,lParam)
end function
调用:
SkinSE_SetMsgCallbackFunction hwnd,addressof CallBackDirectUIHandler
取消回调:
SkinSE_SetMsgCallbackFunction hwnd,0
补充:VB , 基础类