墨香年少 32 发布于 2023年8月11日 you may be find you cannot realy cose the exe only close it in task manager. so we create a button and when we click the close button to real close the exe. the xml code: <?xml version="1.0" encoding="UTF-8"?> <Window size="340,280" caption="0,0,0,35"> <Font id="0" name="Courier New Bold" size="22" bold="false"/> <VerticalLayout> <HorizontalLayout bkcolor="#FFff1a1a"/> <HorizontalLayout> <Button name="btn_close" font="0" text="close app" bkcolor="#FF00b33c"/> </HorizontalLayout> <HorizontalLayout bkcolor="#FFffd633"/> </VerticalLayout> </Window> the app.cpp code: #include "app.h" class MainWndFrame : public WindowImplBase { protected: virtual CDuiString GetSkinFolder() override; virtual CDuiString GetSkinFile() override; virtual LPCTSTR GetWindowClassName(void) const override; virtual DuiLib::UILIB_RESOURCETYPE GetResourceType() const override; virtual LPCTSTR GetResourceID() const override; virtual void InitWindow(); virtual void Notify(TNotifyUI& msg); public: static const LPCTSTR kClassName; static const LPCTSTR kMainWndFrame; CPaintManagerUI m_pm; private: CButtonUI* m_pCloseBtn; }; DuiLib::CDuiString MainWndFrame::GetSkinFolder() { return m_PaintManager.GetInstancePath(); } DuiLib::CDuiString MainWndFrame::GetSkinFile() { return kMainWndFrame; } LPCTSTR MainWndFrame::GetWindowClassName(void) const { return kClassName; } DuiLib::UILIB_RESOURCETYPE MainWndFrame::GetResourceType() const { return UILIB_FILE; } LPCTSTR MainWndFrame::GetResourceID() const { return MAKEINTRESOURCE(101); } void MainWndFrame::InitWindow() { m_pCloseBtn = dynamic_cast<CButtonUI*>(m_pm.FindControl(_T("btn_close"))); } void MainWndFrame::Notify(TNotifyUI& msg) { if (msg.sType == DUI_MSGTYPE_CLICK) { CDuiString strName = msg.pSender->GetName(); if (strName == _T("btn_close")) { PostQuitMessage(0); } } __super::Notify(msg); } const LPCTSTR MainWndFrame::kClassName = _T("main_wnd"); const LPCTSTR MainWndFrame::kMainWndFrame = _T("main_wnd.xml"); int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); // 设置窗口关联的实例 CPaintManagerUI::SetInstance(hInstance); // 设置皮肤的默认路径 CPaintManagerUI::SetCurrentPath(CPaintManagerUI::GetInstancePath()); CPaintManagerUI::SetResourcePath(_T("theme")); // 创建窗口 MainWndFrame* pMainWndFrame = new MainWndFrame; pMainWndFrame->Create(nullptr, MainWndFrame::kClassName, UI_WNDSTYLE_DIALOG, 0); pMainWndFrame->CenterWindow(); pMainWndFrame->ShowWindow(); CPaintManagerUI::MessageLoop(); if (nullptr != pMainWndFrame) { delete pMainWndFrame; } return 0; } 目之所及,皆是回忆,心之所想,皆是过往 分享这篇帖子 链接帖子 分享到其他站点