CMsgWnd.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #pragma once
  2. #define MSGID_OK 1
  3. #define MSGID_CANCEL 0
  4. #include "duilib.h"
  5. class CMsgWnd : public WindowImplBase
  6. {
  7. public:
  8. static int MessageBox(HWND hParent, LPCTSTR lpstrTitle, LPCTSTR lpstrMsg, LPCTSTR lpstrConfirmBtn, LPCTSTR lpstrCancelBtn)
  9. {
  10. CMsgWnd* pWnd = new CMsgWnd();
  11. pWnd->Create(hParent, _T("msgwnd"), WS_POPUP | WS_CLIPCHILDREN, WS_EX_TOOLWINDOW);
  12. pWnd->CenterWindow();
  13. pWnd->SetTitle(lpstrTitle);
  14. pWnd->SetMsg(lpstrMsg);
  15. pWnd->SetConfirmBtn(lpstrConfirmBtn);
  16. pWnd->SetCancelBtn(lpstrCancelBtn);
  17. return pWnd->ShowModal();
  18. }
  19. static int MessageBox(HWND hParent, LPCTSTR lpstrTitle, LPCTSTR lpstrMsg, LPCTSTR lpstrConfirmBtn)
  20. {
  21. CMsgWnd* pWnd = new CMsgWnd();
  22. pWnd->Create(hParent, _T("msgwnd"), WS_POPUP | WS_CLIPCHILDREN, WS_EX_TOOLWINDOW);
  23. pWnd->CenterWindow();
  24. pWnd->SetTitle(lpstrTitle);
  25. pWnd->SetMsg(lpstrMsg);
  26. pWnd->SetConfirmBtn(L"",true);
  27. pWnd->SetCancelBtn(lpstrConfirmBtn);
  28. return pWnd->ShowModal();
  29. }
  30. static int MessageBox(HWND hParent, LPCTSTR lpstrTitle, LPCTSTR lpstrMsg, LPCTSTR lpstrConfirmBtn, UINT_PTR Tag)
  31. {
  32. CMsgWnd* pWnd = new CMsgWnd();
  33. pWnd->Create(hParent, _T("msgwnd"), WS_POPUP | WS_CLIPCHILDREN, WS_EX_TOOLWINDOW);
  34. pWnd->CenterWindow();
  35. pWnd->SetTitle(lpstrTitle);
  36. pWnd->SetMsg(lpstrMsg);
  37. pWnd->SetConfirmBtn(L"",true);
  38. pWnd->SetCancelBtn(lpstrConfirmBtn, Tag);
  39. return pWnd->ShowModal();
  40. }
  41. static void ShowMessageBox(HWND hParent, LPCTSTR lpstrTitle, LPCTSTR lpstrMsg, LPCTSTR lpstrConfirmBtn, LPCTSTR lpstrCancelBtn)
  42. {
  43. CMsgWnd* pWnd = new CMsgWnd();
  44. pWnd->Create(hParent, _T("msgwnd"), UI_WNDSTYLE_FRAME, 0);
  45. pWnd->CenterWindow();
  46. pWnd->SetTitle(lpstrTitle);
  47. pWnd->SetMsg(lpstrMsg);
  48. pWnd->SetConfirmBtn(lpstrConfirmBtn);
  49. pWnd->SetCancelBtn(lpstrCancelBtn);
  50. pWnd->ShowWindow(true);
  51. }
  52. public:
  53. CMsgWnd(void);
  54. ~CMsgWnd(void);
  55. void SetMsg(LPCTSTR lpstrMsg);
  56. void SetTitle(LPCTSTR lpstrTitle);
  57. void SetConfirmBtn(LPCTSTR lpstrConfirmBtn, bool isOnlyConfirmBtn = false);
  58. void SetCancelBtn(LPCTSTR lpstrCancelBtn);
  59. void SetCancelBtn(LPCTSTR lpstrCancelBtn, UINT_PTR Tag);
  60. public:
  61. virtual void OnFinalMessage(HWND);
  62. virtual CDuiString GetSkinFile();
  63. virtual LPCTSTR GetWindowClassName(void) const;
  64. virtual void Notify(TNotifyUI& msg);
  65. virtual void InitWindow();
  66. DUI_DECLARE_MESSAGE_MAP()
  67. virtual void OnClick(TNotifyUI& msg);
  68. virtual LRESULT OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  69. LRESULT HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  70. private:
  71. CButtonUI* m_pCloseBtn;
  72. CButtonUI* m_pMaxBtn;
  73. CButtonUI* m_pRestoreBtn;
  74. CButtonUI* m_pMinBtn;
  75. CButtonUI* m_pMenuBtn;
  76. };