soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SMessageBox.h
1#ifndef __SMESSAGEBOX__H__
2#define __SMESSAGEBOX__H__
3
4#include <core/SHostDialog.h>
5#include <helper/SDpiHelper.hpp>
6#include <interface/SMessageBox-i.h>
7
8SNSBEGIN
9
10// IDs that must be specified in the message box template.
11#define NAME_MSGBOX_BTNSWITCH L"btnSwitch" // Tab control containing 3 pages
12#define NAME_MSGBOX_TEXT L"msgtext" // Text control, only coordinates need to be specified
13#define NAME_MSGBOX_TITLE L"msgtitle" // Title control ID
14#define NAME_MSGBOX_ICON L"msgicon" // Icon display control ID
15#define NAME_MSGBOX_BTN1 L"button1st" // First button ID, will be automatically modified to IDs like IDOK, IDCANCEL, etc.
16#define NAME_MSGBOX_BTN2 L"button2nd" // Second button ID
17#define NAME_MSGBOX_BTN3 L"button3rd" // Third button ID
18
19/**
20 * @class SMessageBoxImpl
21 * @brief Message Box Implementation
22 * @details Implementation class for message boxes. If more personalized message boxes are needed, derive from this class.
23 */
24class SOUI_EXP SMessageBoxImpl
25 : public SHostDialog
26 , public SDpiHandler<SMessageBoxImpl> {
27 public:
28 /**
29 * @brief Constructor
30 */
32
33 /**
34 * @brief Display a message box
35 * @param hWnd Parent window handle
36 * @param lpText Message content
37 * @param lpCaption Window title
38 * @param uType Window type
39 * @return Result of the message box
40 */
41 INT_PTR MessageBox(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType);
42
43 protected:
44 /**
45 * @brief Get the initialization XML node
46 * @param xmlDoc XML document
47 * @return XML node for initialization
48 */
49 SXmlNode OnGetInitXmlNode(SXmlDoc &xmlDoc) override;
50
51 /**
52 * @brief Initialize the dialog
53 * @param wnd Host window handle
54 * @param lInitParam Initialization parameter (not used)
55 * @return TRUE if successful, FALSE otherwise
56 */
57 BOOL OnInitDialog(HWND wnd, LPARAM lInitParam);
58
59 /**
60 * @brief Set the icon
61 * @param uType Icon type
62 * @return TRUE if successful, FALSE otherwise
63 * @details Set the icon. This method can be overridden to display custom icons.
64 */
65 virtual BOOL OnSetIcon(UINT uType);
66
67 /**
68 * @brief Get the button text
69 * @param nBtnID Button ID
70 * @return Button text
71 */
72 virtual SStringT OnGetButtonText(int nBtnID) const;
73
74 /**
75 * @brief Handle button click event
76 * @param uID Control ID
77 * @details Message handler for button clicks.
78 */
79 void OnBtnClick(int uID)
80 {
81 EndDialog(uID);
82 }
83
84 EVENT_MAP_BEGIN()
85 EVENT_ID_COMMAND_RANGE(IDOK, IDNO, OnBtnClick)
86 EVENT_MAP_END2(SHostDialog)
87
88 BEGIN_MSG_MAP_EX(SMessageBoxImpl)
89 MSG_WM_INITDIALOG(OnInitDialog)
90 CHAIN_MSG_MAP(SDpiHandler<SMessageBoxImpl>)
91 CHAIN_MSG_MAP(SHostDialog)
92 REFLECT_NOTIFICATIONS_EX()
93 END_MSG_MAP()
94};
95
96SNSEND
97
98#endif // __SMESSAGEBOX__H__
SOUI Dialog Module.
处理DPI变化的模板类
Dialog host window class.
Definition SHostDialog.h:30
void EndDialog(INT_PTR nResult) OVERRIDE
Ends the dialog.
SHostDialog(LPCWSTR pszXmlName=NULL)
Constructor.
virtual SXmlNode OnGetInitXmlNode(SXmlDoc &xmlDoc)
Gets the initial XML node.
Definition shostwnd.cpp:827
virtual SStringT OnGetButtonText(int nBtnID) const
Get the button text.
void OnBtnClick(int uID)
Handle button click event.
Definition SMessageBox.h:79
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.
Implementation of IXmlDoc.
Definition SXml.h:912
Class representing an XML node.
Definition SXml.h:352