关于 作用域 的 callback 问题

hcmfys 2009-02-14 04:26:20
比如
text.h
clas CDynViewsDlg::CWND{
void CALLBACK CDynViewsDlg::TimerProc(HWND hWnd,UINT nMsg,UINT nTimerid,DWORD dwTime)
}

请问大家 有作用域的 callback 函数 怎么用呢??

text.cpp
要调用

SetTimer(id,1000,CDynViewsDlg::TimerProc);

为什么不对呢??
...全文
96 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
yueyinggufan 2009-02-14
  • 打赏
  • 举报
回复
成员函数指针要定义成
void(A::*p)();
赋值要写成
p=&A::.test; //成员函数
yueyinggufan 2009-02-14
  • 打赏
  • 举报
回复
其实一样的,你可以用一个函数指针指向这个回调函数,然后把其传入 SetTimer内
waizqfor 2009-02-14
  • 打赏
  • 举报
回复
函数声明 CALLBACK 的

HRESULT CallBack(
IShellFolder *psf,
HWND hwndOwner,
IDataObject *pdtobj,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);

psf
[in] A pointer to the IShellFolder interface of the object that supports the IContextMenuCB::CallBack interface. The context menu interface is returned on a call to IShellFolder::GetUIObjectOf.
hwndOwner
[in] A handle to the owner of the context menu.
pdtobj
[in] A pointer to an IDataObject that contains information about a menu selection. Implement interface IDataObject, or call SHCreateDataObject for the default implementation.
uMsg
[in] A notification from the Shell's default menu implementation. For example, the default menu implementation calls DFM_MERGECONTEXTMENU to allow the implementer of IContextMenuCB::CallBack to remove, add, or disable context menu items in this callback. Use one of the following notifications.
DFM_MERGECONTEXTMENU
DFM_INVOKECOMMAND
DFM_GETHELPTEXT
DFM_GETHELPTEXTW
DFM_WM_MEASUREITEM
DFM_WM_DRAWITEM
DFM_WM_INITMENUPOPUP
DFM_VALIDATECMD
DFM_INVOKECOMMANDEX
DFM_MAPCOMMANDNAME
DFM_GETDEFSTATICID
DFM_GETVERB
DFM_MERGECONTEXTMENU_BOTTOM


wParam
[in] Data specific to the notification specified in uMsg. See the individual notification page for specific requirements.
lParam
[in] Data specific to the notification specified in uMsg. See the individual notification page for specific requirements.
Return Value

Returns S_OK if successful, or an error value otherwise.
arong1234 2009-02-14
  • 打赏
  • 举报
回复
没有这种声明作用域得,不知道你从哪看来得
你这个不对得原因是TimerProc要么必须不是类成员函数,要么必须是static成员函数。不可以是普通类成员函数

65,211

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧