Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cWndDialog.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cWndDialog_H
7 #define _INC_cWndDialog_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "cWindow.h"
13 #if defined(_WIN32) && ! defined(_MFC_VER)
14 
15 namespace GrayLib
16 {
17  class GRAYLIB_LINK cWndDialogBase : public cWndHandle
18  {
22 
23  typedef cWndHandle SUPER_t;
24 
25  protected:
26  virtual bool OnInitDialog(LPARAM lParam);
27  virtual bool OnCommand(DLGID_t wID, HWND hwndCtl, WORD wNotifyCode);
28  virtual void OnMove(POINTS pt);
29 
30  virtual BOOL DefDialogProc(WINMSG_t message, WPARAM wParam, LPARAM lParam);
31 
32  public:
33  virtual ~cWndDialogBase();
34 
35  INT_PTR DoModal(DLGID_t idResource, HWND hWndParent = HWND_DESKTOP);
36  bool EndDialog(INT_PTR nRetCode);
37 
38  bool CreateDialogX(DLGID_t idDialog, HWND hWndParent);
39 
40  bool IsDialogMessageX(MSG* pMsg) const
41  {
44  return ::_GTN(IsDialogMessage)(m_hWnd, pMsg);
45  }
46 
47  void SetDefID(DLGID_t nID)
48  {
49  SendMessageX(DM_SETDEFID, nID, 0);
50  }
51  DLGID_t GetDefID() const
52  {
53  return DLGID_t(SendMessageX(DM_GETDEFID, 0, 0));
54  }
55 
56  static DLGID_t GRAYCALL SetDefaultButton(HWND hWndDlg, DLGID_t idNew, DLGID_t idPrev);
57  static INT_PTR CALLBACK DialogProc(HWND hWnd, WINMSG_t message, WPARAM wParam, LPARAM lParam);
58  };
59 
60  class GRAYLIB_LINK CDataExchange
61  {
64  };
65 
66  class GRAYLIB_LINK cWndDialog : public cWndDialogBase
67  {
72 
73 #define DECLARE_MESSAGE_MAP() // virtual BOOL DefDialogProc( WINMSG_t message, WPARAM wParam, LPARAM lParam );
74 #define BEGIN_MESSAGE_MAP(_TYPE, _TBASE) // __noop??
75 #define END_MESSAGE_MAP() // __noop??
76 
77  typedef cWndDialogBase SUPER_t;
78 
79  public:
80  const DLGID_t m_IDD; // my resource id. may be same as my GetDlgCtrlID()
81  cWndHandle* m_pParent;
82  bool m_bIsInInit; // I'm initing the controls. Ignore any change messages.
83 
84  protected:
85  virtual void DoDataExchange(CDataExchange* pDX) // MFC DDX/DDV support
86  {
88  }
89 
90  public:
91  cWndDialog(DLGID_t idd, cWndHandle* pParent = nullptr)
92  : m_IDD(idd)
93  , m_pParent(pParent)
94  , m_bIsInInit(false)
95  {
96  }
97 
98  virtual DLGID_t GetDlgCtrlID() const
99  {
101  return m_IDD;
102  }
103  DLGID_t get_SortValue() const noexcept
104  {
105  return m_IDD;
106  }
107 
108  HWND GetParent2() const
109  {
110  if (m_pParent != nullptr)
111  return m_pParent->get_Hwnd();
112  if (isValidHwnd())
113  return GetParent();
114  return WINHANDLE_NULL;
115  }
116 
117  INT_PTR DoModal(HWND hWndParent = HWND_DESKTOP)
118  {
119  if (hWndParent == HWND_DESKTOP)
120  {
121  hWndParent = GetParent2();
122  }
123  return SUPER_t::DoModal(m_IDD, hWndParent);
124  }
125  bool CreateDialogX()
126  {
127  return SUPER_t::CreateDialogX(m_IDD, GetParent2());
128  }
129  };
130 };
131 #endif // _MSC_VER
132 #endif // _INC_cWndDialog_H
#define GRAYCALL
declare calling convention for static functions so everyone knows the arg passing scheme....
Definition: GrayCore.h:36
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
#define _GTN(c)
_WIN32 name has a A or W for UTF8 or UNICODE (like _FNF)
Definition: StrConst.h:28
#define UNREFERENCED_PARAMETER(P)
< _WIN32 type thing. get rid of stupid warning.
Definition: SysTypes.h:299
UINT WINMSG_t
Supplement _WIN32 "windows.h".
Definition: WinTypes.h:111
#define WINHANDLE_NULL
HWND, HPEN, etc are NOT OS Handles. like HWND_DESKTOP. like HANDLEPTR_NULL. This is a WINAPI void* ha...
Definition: cOSHandle.h:23
Definition: cMesh.h:22
UINT DLGID_t
old window format this was a WORD, EX format this is UINT32.
Definition: cResDialog.h:68