yourwcd 发表于 2007-1-22 11:10:00

请教回掉函数问题

<p>WNDPROC procOld;<br/>LRESULT CALLBACK NewAcadWndProc(<br/>&nbsp; HWND hwnd,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // handle to window<br/>&nbsp; UINT uMsg,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // message identifier<br/>&nbsp; WPARAM wParam,&nbsp; // first message parameter<br/>&nbsp; LPARAM lParam&nbsp;&nbsp; // second message parameter<br/>);<br/>class CmyToolbar2App : public AcRxArxApp {</p><p>public:<br/>LRESULT CALLBACK NewAcadWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) <br/>{ <br/>switch(iMsg) <br/>{ <br/>case WM_MOUSEMOVE: <br/>//lParam = MAKELPARAM(200,200);//禁止移动光标 <br/>break; <br/>case WM_LBUTTONDOWN: <br/>AfxMessageBox("WM_LBUTTONDOWN");//响应鼠标左键 <br/>break; <br/>case WM_MOUSEWHEEL: <br/>AfxMessageBox("WM_MOUSEWHEEL");//响应鼠标滚动 <br/>break; <br/>default: <br/>break; <br/>} <br/>return ::CallWindowProc(procOld, hwnd, iMsg, wParam, lParam); <br/>} <br/>&nbsp;CmyToolbar2App () : AcRxArxApp () {}</p><p>&nbsp;virtual AcRx::AppRetCode On_kInitAppMsg (void *pkt) {<br/>&nbsp;&nbsp;AcRx::AppRetCode retCode =AcRxArxApp::On_kInitAppMsg (pkt) ;</p><p>&nbsp;procOld = (WNDPROC)::SetWindowLong(acedGetAcadDwgView()-&gt;GetSafeHwnd(),GWL_WNDPROC, (LONG)NewAcadWndProc); <br/>&nbsp;&nbsp;&nbsp;CAcModuleResourceOverride resOverride;</p><p>&nbsp;&nbsp;return (retCode) ;<br/>&nbsp;}<br/>} ;<br/>&nbsp;</p><p>这一行有错误:<br/>&nbsp;procOld = (WNDPROC)::SetWindowLong(acedGetAcadDwgView()-&gt;GetSafeHwnd(),GWL_WNDPROC, (LONG)NewAcadWndProc); <br/>&nbsp;&nbsp;&nbsp;CAcModuleResourceOverride resOverride; <br/>包错信息:</p><p>e:\AutoCad二次开发\我的演示\myToolbar2\acrxEntryPoint.cpp(96) : error C2440: “类型转换” : 无法从“LRESULT (__stdcall CmyToolbar2App::* )(HWND,UINT,WPARAM,LPARAM)”转换为“LONG”<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 转换是有效的标准转换,可以隐式执行或通过使用 static_cast、C 样式转换或函数样式转换执行 </p><p><br/>相似的回掉函数在MFC工程中却没有报错 </p>

yourwcd 发表于 2007-1-30 10:33:00

<p>问题解决,代码如下:</p><p>WNDPROC procOld;<br/>LRESULT CALLBACK NewAcadWndProc(<br/>&nbsp; HWND hwnd,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // handle to window<br/>&nbsp; UINT uMsg,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // message identifier<br/>&nbsp; WPARAM wParam,&nbsp; // first message parameter<br/>&nbsp; LPARAM lParam&nbsp;&nbsp; // second message parameter<br/>);</p><p>LRESULT CALLBACK NewAcadWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) <br/>{ <br/>switch(iMsg) <br/>{ <br/>case WM_MOUSEMOVE: <br/>//lParam = MAKELPARAM(200,200);//禁止移动光标 <br/>break; <br/>case WM_LBUTTONDOWN: <br/>AfxMessageBox("WM_LBUTTONDOWN");//响应鼠标左键 <br/>break; <br/>case WM_MOUSEWHEEL: <br/>AfxMessageBox("WM_MOUSEWHEEL");//响应鼠标滚动 <br/>break; <br/>default: <br/>break; <br/>} <br/>return ::CallWindowProc(procOld, hwnd, iMsg, wParam, lParam); <br/>} <br/><br/>class CmyToolbar2App : public AcRxArxApp {</p><p>public:<br/>&nbsp;CmyToolbar2App () : AcRxArxApp () {}</p><p>&nbsp;virtual AcRx::AppRetCode On_kInitAppMsg (void *pkt) {<br/>&nbsp;&nbsp;AcRx::AppRetCode retCode =AcRxArxApp::On_kInitAppMsg (pkt) ;</p><p>&nbsp;procOld = (WNDPROC)::SetWindowLong(acedGetAcadDwgView()-&gt;GetSafeHwnd(),GWL_WNDPROC, (LONG)NewAcadWndProc); <br/>&nbsp;&nbsp;&nbsp;CAcModuleResourceOverride resOverride;</p><p>&nbsp;&nbsp;return (retCode) ;<br/>&nbsp;}<br/>} ;</p>
页: [1]
查看完整版本: 请教回掉函数问题