企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
```c++ #include <Windows.h> #include "../DuiLib/UIlib.h" #include <iostream> using namespace DuiLib; using namespace std; #ifdef _DEBUG # ifdef _UNICODE # pragma comment(lib, "DuiLib.lib") # else # pragma comment(lib, "DuiLib_d.lib") # endif #else # ifdef _UNICODE # pragma comment(lib, "DuiLib.lib") # else # pragma comment(lib, "DuiLib_d.lib") # endif #endif class CDuiFramWnd : public CWindowWnd, public INotifyUI { public : virtual LPCTSTR GetWindowClassName()const {return _T("DUIMainFram");} virtual void Notify(TNotifyUI& msg){ if (msg.sType == _T("click")) { if (msg.pSender->GetName() == _T("btmHello")) ::MessageBox(NULL,_T("我是按钮"),_T("点击了按钮"),MB_OK); } } virtual LRESULT HandleMessage(UINT uMsg,WPARAM wParam,LPARAM lParam) { //WM_NCCALCSIZE WM_NCCALCSIZE WM_NCPAINT 禁用标题栏 LRESULT lRes = 0; switch(uMsg) { case WM_CREATE: { CControlUI* pWnd = new CButtonUI; pWnd->SetName(_T("btmHello"));//控件唯一标识,必须唯一 pWnd->SetText(_T("Hello World")); pWnd->SetBkColor(0xFF00FF00); // 设置背景色 m_PaintManager.Init(m_hWnd); m_PaintManager.AttachDialog(pWnd); m_PaintManager.AddNotifier(this);//添加控件消息相应,消息会传达到duilib 的消息循环,可以在Notify函数里做消息处理 return lRes; } case WM_NCACTIVATE: { if (!::IsIconic(m_hWnd)) return (wParam == 0) ? TRUE : FALSE; } case WM_NCCALCSIZE: return FALSE; case WM_NCPAINT: return FALSE; } if( m_PaintManager.MessageHandler(uMsg, wParam, lParam, lRes) ) { return lRes; } return __super::HandleMessage(uMsg, wParam, lParam); } protected: CPaintManagerUI m_PaintManager; }; int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow) { CPaintManagerUI::SetInstance(hInstance); CDuiFramWnd duiFrame; duiFrame.Create(NULL, _T("DUIWnd"), UI_WNDSTYLE_FRAME, WS_EX_WINDOWEDGE); duiFrame.ShowModal(); return 0; }