ATL窗口(初学者)

    技术2022-05-11  16

    1) 新建一个Win32 Application 2) 我们要用到atl的东西,添加atl头文件支持. <atlbase.h> Extern CcomModule _Module; <atlwin.h> 3)打算使用WindowImpl来实现我们的窗口类, Typedef CwinTraits<> AtlwindowTraits; CatlWindow : public WindowImpl<CatlWindow,Cwindow, AtlwindowTraits> 我们的类要从WindowImpl派生,必须重载processWindowMessage(处理消息用) Virtual bool ProcessWindowMessage(……………….) { Switch(uMsg) {        Case WM_CREATE:        Break;        Case WM_DESTROY:        PostQuitMessage(0);        Break; } Return false } 3)在WinMain中添加以下代码,别忘了定义全局Module        _Module.Init(NULL,hInstance);        atlwindow lvrong;        lvrong.Create(0,CWindow::rcDefault,__T("lvrong's Application"),WS_OVERLAPPEDWINDOW,WS_EX_CLIENTEDGE);        lvrong.CenterWindow();        lvrong.ShowWindow(nCmdShow);        lvrong.UpdateWindow();        MSG msg;        while(GetMessage(&msg,NULL,NULL,NULL))        {               TranslateMessage(&msg);               DispatchMessage(&msg);                      }        _Module.Term(); 4)F7运行,我的第一个Atl的窗口出来了~

    最新回复(0)