Duilib 弹出子对话框

本文介绍如何在Duilib框架下弹出子对话框。通过定义自定义对话框类并配合XML文件实现子对话框的创建与显示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

要在Duilib中弹出子对话框,首先定义一个需要弹出的自对话框的类,例子如下:

class CInstall : public CWindowWnd, public INotifyUI, public IMessageFilterUI
{
public:
	CInstall()
	{

	};
	virtual ~CInstall()
	{
		DestroyWindow(GetParent(this->GetHWND()));
	};
	LPCTSTR GetWindowClassName() const { return _T("UILoginFrame"); };
	UINT GetClassStyle() const { return UI_CLASSSTYLE_DIALOG; };
	void OnFinalMessage(HWND /*hWnd*/)
	{
		m_pm.RemovePreMessageFilter(this);
		delete this;
	};

	void Init() {
		CComboUI* pAccountCombo = static_cast<CComboUI*>(m_pm.FindControl(_T("accountcombo")));
		CEditUI* pAccountEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("accountedit")));
		// 初始化CProgressUI控件
		CProgressUI* pProgress = static_cast<CProgressUI*>(m_pm.FindControl(_T("ProgressDemo1")));
		pProgress->SetValue(80);
		if (pAccountCombo && pAccountEdit) pAccountEdit->SetText(pAccountCombo->GetText());
		pAccountEdit->SetFocus();
	}

	void Notify(TNotifyUI& msg)
	{
	}

	LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		LONG styleValue = ::GetWindowLong(*this, GWL_STYLE);
		styleValue &= ~WS_CAPTION;
		::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);

		m_pm.Init(m_hWnd);
		m_pm.AddPreMessageFilter(this);
		CDialogBuilder build
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值