要在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