在dll中,如何在自定义类中建立消息循环机制

fraudVR 2003-04-06 07:55:25
请教各位大侠:
我在dll中定义了一个类,在这个类中,我要处理消息,比如定时消息,还有其他的消息,我怎么才能够获得消息,并且用处理消息?
我打算在自定义类中注册一个隐含窗口,然后用这个窗口的消息队列,但不知道怎么注册窗口不成功,请问为什么??
...全文
118 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
kingzai 2003-04-07
  • 打赏
  • 举报
回复
haven't tried this code, you might have to tweak :

#define EXP_CALL __declspec(dllexport) __stdcall
#define MY_WNDCLASS "DDE_DllWndClass"

WNDCLASS DdeWndClass ;

// Define and register the Window class :
DdeWndClass.style = CS_NOCLOSE ;
DdeWndClass.lpfnWndProc = (WNDPROC) MyDDE_WndProc;
DdeWndClass.cbClsExtra = 0;
DdeWndClass.cbWndExtra = 0;
DdeWndClass.hInstance = hInstance;
DdeWndClass.hIcon = 0;
DdeWndClass.hCursor = 0 ;
DdeWndClass.hbrBackground = GetStockObject (WHITE_BRUSH);
DdeWndClass.lpszMenuName = NULL ;
DdeWndClass.lpszClassName = MY_WNDCLASS;

if (RegisterClass (&DdeWndClass))
{
hDdeWnd = CreateWindow (MY_WNDCLASS,
"",
WS_DISABLED,
0,
0,
100,
50,
HWND_DESKTOP,
0,
hInstance,
NULL);
}

LRESULT EXP_CALL MyDDE_WndProc (HWND hWnd,
WORD wMessage,
WPARAM wParam,
LPARAM lParam)
{
switch (wMessage)
{
case WM_DDE_ACK:
Handler_DdeAck (wParam, lParam);
break;

// whatever else you want...

default :
return (DefWindowProc(hWnd, wMessage, wParam, lParam));
} return FALSE ;
}
In355Hz 2003-04-06
  • 打赏
  • 举报
回复
关注
webber84 2003-04-06
  • 打赏
  • 举报
回复
不成功是什么意思?
o_racle 2003-04-06
  • 打赏
  • 举报
回复
dll 中没有消息机制的

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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