3#include "control/SMessageBox.h"
15static struct MsgBoxInfo
26 return ::MessageBox(hWnd, lpText, lpCaption, uType);
27 s_MsgBoxInfo.pszText = lpText;
28 s_MsgBoxInfo.pszCaption = lpCaption;
29 s_MsgBoxInfo.uType = uType;
46 case MB_ICONINFORMATION:
72 { 1, { { IDOK, L
"ok" }, { 0, L
"" }, { 0, L
"" } } },
74 { 2, { { IDOK, L
"ok" }, { IDCANCEL, L
"cancel" }, { 0, L
"" } } },
76 { 3, { { IDABORT, L
"abort" }, { IDRETRY, L
"retry" }, { IDIGNORE, L
"ignore" } } },
78 { 3, { { IDYES, L
"yes" }, { IDNO, L
"no" }, { IDCANCEL, L
"cancel" } } },
80 { 2, { { IDYES, L
"yes" }, { IDNO, L
"no" }, { 0, L
"" } } },
82 { 2, { { IDRETRY, L
"retry" }, { IDCANCEL, L
"cancel" }, { 0, L
"" } } }
85const WCHAR *g_wcsNameOfBtns[] = { NAME_MSGBOX_BTN1, NAME_MSGBOX_BTN2, NAME_MSGBOX_BTN3 };
100 UINT uType = s_MsgBoxInfo.uType & 0x0F;
104 pBtnSwitch->
SetCurSel(g_msgBtnText[uType].nBtns - 1);
105 SWindow *pBtnPanel = pBtnSwitch->
GetItem(g_msgBtnText[uType].nBtns - 1);
109 for (
int i = 0; i < g_msgBtnText[uType].nBtns; i++)
112 int nID = g_msgBtnText[uType].btnInfo[i].uBtnID;
117 if (strText.IsEmpty())
119 SStringW strBtnText = g_msgBtnText[uType].btnInfo[i].szText;
124 strBtnText = nodeTxt.
Text();
126 strBtnText = GETSTRING(strBtnText);
130 strText = S_CW2T(
GetRoot()->tr(strBtnText));
134 pBtn->SetAttribute(L
"accel", strAccel, TRUE);
140 SStringWList lstMinSize;
141 SplitString(strMinSize, L
',', lstMinSize);
142 SASSERT(lstMinSize.GetCount() == 2);
148 if (s_MsgBoxInfo.pszCaption)
149 strTitle = s_MsgBoxInfo.pszCaption;
160 CSize szWnd = rcWnd.Size();
166 SetWindowPos(0, 0, 0, szWnd.cx, szWnd.cy, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
169 SetForegroundWindow(
m_hWnd);
170 SetMsgHandled(FALSE);
175INT_PTR SMessageBox(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType)
178 return msgBox.
MessageBox(hWnd, lpText, lpCaption, uType);
Definition of the STabCtrl and related classes.
SXmlNode GetMessageBoxTemplate() const
Get the message box template XML node.
INT_PTR DoModal(HWND hParent=0, DWORD dwStyle=WS_POPUP|WS_CLIPCHILDREN, DWORD dwExStyle=0) OVERRIDE
Displays the dialog as a modal window.
SHostDialog(LPCWSTR pszXmlName=NULL)
Constructor.
SWindow * FindChildByName(LPCWSTR strName, int nDeep=-1)
Finds a child window by its name (Unicode version).
T * FindChildByName2(LPCWSTR pszName, int nDeep=-1)
Finds a child window by its name (Unicode version) with template support.
CRect GetWindowRect() const
Gets the window rectangle.
SWindow * GetRoot() const
Gets the root window.
LPCWSTR GetTranslatorContext() const OVERRIDE
Gets the translator context for the container.
int GetScale() const OVERRIDE
Gets the scale factor for the container.
BOOL SetIcon(int nSubID) OVERRIDE
设置图标
int toPixelSize(int scale) const
将大小转换为像素值
static SLayoutSize fromString(const SStringW &strSize)
从字符串创建大小对象
Message Box Implementation.
virtual SStringT OnGetButtonText(int nBtnID) const
Get the button text.
SXmlNode OnGetInitXmlNode(SXmlDoc &xmlDoc) override
Get the initialization XML node.
SMessageBoxImpl()
Constructor.
virtual BOOL OnSetIcon(UINT uType)
Set the icon.
INT_PTR MessageBox(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType)
Display a message box.
BOOL OnInitDialog(HWND wnd, LPARAM lInitParam)
Initialize the dialog.
HWND m_hWnd
Handle to the window.
void SetID(int nID) OVERRIDE
Sets the object's ID.
static SApplication * getSingletonPtr(void)
A class representing an ASCII string.
void TrimBlank()
Trims leading and trailing whitespace characters from the string.
BOOL IsEmpty() SCONST
Checks if the string is empty.
A tab control for managing multiple tab pages.
STabPage * GetItem(int iPage)
Gets a tab page by index.
BOOL SetCurSel(int nIndex) OVERRIDE
Sets the currently selected tab page.
Base class for SOUI DUI windows.
void SetVisible(BOOL bVisible, BOOL bUpdate=FALSE) OVERRIDE
Sets the visibility of the window.
int GetWindowText(TCHAR *pBuf, int nBufLen, BOOL bRawText) OVERRIDE
Retrieves the window text.
SWindow * FindChildByName(LPCWSTR strName, int nDeep=-1)
Finds a child window by its name.
void UpdateLayout() OVERRIDE
Updates the layout of the window.
void SetWindowText(LPCTSTR lpszText) OVERRIDE
Sets the window text.
const wchar_t * as_string(const wchar_t *def=L"") const
Gets the attribute value as a string.
const wchar_t * value() const
Gets the attribute value.
Implementation of IXmlDoc.
Class representing an XML node.
SXmlAttr attribute(const wchar_t *name, bool bCaseSensitive=false) const
Gets the attribute with the specified name.
SXmlNode child(const wchar_t *name, bool bCaseSensitive=false) const
Gets the child node, attribute, or next/previous sibling with the specified name.
const wchar_t * Text() SCONST OVERRIDE
Gets the node text.