diff options
author | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2023-06-21 00:00:00 +0000 |
---|---|---|
committer | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2023-12-17 14:59:19 +0500 |
commit | 5b39dc76f1bc82f941d5c800ab9f34407a06b53a (patch) | |
tree | fe5e17420300b715021a76328444088d32047963 /CPP/Windows/Control/Dialog.h | |
parent | 93be7d4abfd4233228f58ee1fbbcd76d91be66a4 (diff) | |
download | 7zip-23.01.tar.gz 7zip-23.01.tar.bz2 7zip-23.01.zip |
23.0123.01
Diffstat (limited to '')
-rw-r--r-- | CPP/Windows/Control/Dialog.h | 114 |
1 files changed, 59 insertions, 55 deletions
diff --git a/CPP/Windows/Control/Dialog.h b/CPP/Windows/Control/Dialog.h index 8a39e99..06be4bf 100644 --- a/CPP/Windows/Control/Dialog.h +++ b/CPP/Windows/Control/Dialog.h | |||
@@ -1,7 +1,7 @@ | |||
1 | // Windows/Control/Dialog.h | 1 | // Windows/Control/Dialog.h |
2 | 2 | ||
3 | #ifndef __WINDOWS_CONTROL_DIALOG_H | 3 | #ifndef ZIP7_INC_WINDOWS_CONTROL_DIALOG_H |
4 | #define __WINDOWS_CONTROL_DIALOG_H | 4 | #define ZIP7_INC_WINDOWS_CONTROL_DIALOG_H |
5 | 5 | ||
6 | #include "../Window.h" | 6 | #include "../Window.h" |
7 | 7 | ||
@@ -10,65 +10,66 @@ namespace NControl { | |||
10 | 10 | ||
11 | class CDialog: public CWindow | 11 | class CDialog: public CWindow |
12 | { | 12 | { |
13 | // Z7_CLASS_NO_COPY(CDialog) | ||
13 | public: | 14 | public: |
14 | CDialog(HWND wnd = NULL): CWindow(wnd){}; | 15 | CDialog(HWND wnd = NULL): CWindow(wnd) {} |
15 | virtual ~CDialog() {}; | 16 | virtual ~CDialog() {} |
16 | 17 | ||
17 | HWND GetItem(int itemID) const | 18 | HWND GetItem(unsigned itemID) const |
18 | { return GetDlgItem(_window, itemID); } | 19 | { return GetDlgItem(_window, (int)itemID); } |
19 | 20 | ||
20 | bool EnableItem(int itemID, bool enable) const | 21 | bool EnableItem(unsigned itemID, bool enable) const |
21 | { return BOOLToBool(::EnableWindow(GetItem(itemID), BoolToBOOL(enable))); } | 22 | { return BOOLToBool(::EnableWindow(GetItem(itemID), BoolToBOOL(enable))); } |
22 | 23 | ||
23 | bool ShowItem(int itemID, int cmdShow) const | 24 | bool ShowItem(unsigned itemID, int cmdShow) const |
24 | { return BOOLToBool(::ShowWindow(GetItem(itemID), cmdShow)); } | 25 | { return BOOLToBool(::ShowWindow(GetItem(itemID), cmdShow)); } |
25 | 26 | ||
26 | bool ShowItem_Bool(int itemID, bool show) const | 27 | bool ShowItem_Bool(unsigned itemID, bool show) const |
27 | { return ShowItem(itemID, show ? SW_SHOW: SW_HIDE); } | 28 | { return ShowItem(itemID, show ? SW_SHOW: SW_HIDE); } |
28 | 29 | ||
29 | bool HideItem(int itemID) const { return ShowItem(itemID, SW_HIDE); } | 30 | bool HideItem(unsigned itemID) const { return ShowItem(itemID, SW_HIDE); } |
30 | 31 | ||
31 | bool SetItemText(int itemID, LPCTSTR s) | 32 | bool SetItemText(unsigned itemID, LPCTSTR s) |
32 | { return BOOLToBool(SetDlgItemText(_window, itemID, s)); } | 33 | { return BOOLToBool(SetDlgItemText(_window, (int)itemID, s)); } |
33 | 34 | ||
34 | bool SetItemTextA(int itemID, LPCSTR s) | 35 | bool SetItemTextA(unsigned itemID, LPCSTR s) |
35 | { return BOOLToBool(SetDlgItemTextA(_window, itemID, s)); } | 36 | { return BOOLToBool(SetDlgItemTextA(_window, (int)itemID, s)); } |
36 | 37 | ||
37 | bool SetItemText_Empty(int itemID) | 38 | bool SetItemText_Empty(unsigned itemID) |
38 | { return SetItemText(itemID, TEXT("")); } | 39 | { return SetItemText(itemID, TEXT("")); } |
39 | 40 | ||
40 | #ifndef _UNICODE | 41 | #ifndef _UNICODE |
41 | bool SetItemText(int itemID, LPCWSTR s) | 42 | bool SetItemText(unsigned itemID, LPCWSTR s) |
42 | { | 43 | { |
43 | CWindow window(GetItem(itemID)); | 44 | CWindow window(GetItem(itemID)); |
44 | return window.SetText(s); | 45 | return window.SetText(s); |
45 | } | 46 | } |
46 | #endif | 47 | #endif |
47 | 48 | ||
48 | UINT GetItemText(int itemID, LPTSTR string, int maxCount) | 49 | UINT GetItemText(unsigned itemID, LPTSTR string, unsigned maxCount) |
49 | { return GetDlgItemText(_window, itemID, string, maxCount); } | 50 | { return GetDlgItemText(_window, (int)itemID, string, (int)maxCount); } |
50 | #ifndef _UNICODE | 51 | #ifndef _UNICODE |
51 | /* | 52 | /* |
52 | bool GetItemText(int itemID, LPWSTR string, int maxCount) | 53 | bool GetItemText(unsigned itemID, LPWSTR string, int maxCount) |
53 | { | 54 | { |
54 | CWindow window(GetItem(itemID)); | 55 | CWindow window(GetItem(unsigned)); |
55 | return window.GetText(string, maxCount); | 56 | return window.GetText(string, maxCount); |
56 | } | 57 | } |
57 | */ | 58 | */ |
58 | #endif | 59 | #endif |
59 | 60 | ||
60 | bool GetItemText(int itemID, UString &s) | 61 | bool GetItemText(unsigned itemID, UString &s) |
61 | { | 62 | { |
62 | CWindow window(GetItem(itemID)); | 63 | CWindow window(GetItem(itemID)); |
63 | return window.GetText(s); | 64 | return window.GetText(s); |
64 | } | 65 | } |
65 | 66 | ||
66 | bool SetItemInt(int itemID, UINT value, bool isSigned) | 67 | bool SetItemInt(unsigned itemID, UINT value, bool isSigned) |
67 | { return BOOLToBool(SetDlgItemInt(_window, itemID, value, BoolToBOOL(isSigned))); } | 68 | { return BOOLToBool(SetDlgItemInt(_window, (int)itemID, value, BoolToBOOL(isSigned))); } |
68 | bool GetItemInt(int itemID, bool isSigned, UINT &value) | 69 | bool GetItemInt(unsigned itemID, bool isSigned, UINT &value) |
69 | { | 70 | { |
70 | BOOL result; | 71 | BOOL result; |
71 | value = GetDlgItemInt(_window, itemID, &result, BoolToBOOL(isSigned)); | 72 | value = GetDlgItemInt(_window, (int)itemID, &result, BoolToBOOL(isSigned)); |
72 | return BOOLToBool(result); | 73 | return BOOLToBool(result); |
73 | } | 74 | } |
74 | 75 | ||
@@ -80,7 +81,7 @@ public: | |||
80 | LRESULT SendMsg_NextDlgCtl(WPARAM wParam, LPARAM lParam) | 81 | LRESULT SendMsg_NextDlgCtl(WPARAM wParam, LPARAM lParam) |
81 | { return SendMsg(WM_NEXTDLGCTL, wParam, lParam); } | 82 | { return SendMsg(WM_NEXTDLGCTL, wParam, lParam); } |
82 | LRESULT SendMsg_NextDlgCtl_HWND(HWND hwnd) { return SendMsg_NextDlgCtl((WPARAM)hwnd, TRUE); } | 83 | LRESULT SendMsg_NextDlgCtl_HWND(HWND hwnd) { return SendMsg_NextDlgCtl((WPARAM)hwnd, TRUE); } |
83 | LRESULT SendMsg_NextDlgCtl_CtlId(int id) { return SendMsg_NextDlgCtl_HWND(GetItem(id)); } | 84 | LRESULT SendMsg_NextDlgCtl_CtlId(unsigned id) { return SendMsg_NextDlgCtl_HWND(GetItem(id)); } |
84 | LRESULT SendMsg_NextDlgCtl_Next() { return SendMsg_NextDlgCtl(0, FALSE); } | 85 | LRESULT SendMsg_NextDlgCtl_Next() { return SendMsg_NextDlgCtl(0, FALSE); } |
85 | LRESULT SendMsg_NextDlgCtl_Prev() { return SendMsg_NextDlgCtl(1, FALSE); } | 86 | LRESULT SendMsg_NextDlgCtl_Prev() { return SendMsg_NextDlgCtl(1, FALSE); } |
86 | 87 | ||
@@ -90,26 +91,27 @@ public: | |||
90 | bool IsMessage(LPMSG message) | 91 | bool IsMessage(LPMSG message) |
91 | { return BOOLToBool(IsDialogMessage(_window, message)); } | 92 | { return BOOLToBool(IsDialogMessage(_window, message)); } |
92 | 93 | ||
93 | LRESULT SendItemMessage(int itemID, UINT message, WPARAM wParam, LPARAM lParam) | 94 | LRESULT SendItemMessage(unsigned itemID, UINT message, WPARAM wParam, LPARAM lParam) |
94 | { return SendDlgItemMessage(_window, itemID, message, wParam, lParam); } | 95 | { return SendDlgItemMessage(_window, (int)itemID, message, wParam, lParam); } |
95 | 96 | ||
96 | bool CheckButton(int buttonID, UINT checkState) | 97 | bool CheckButton(unsigned buttonID, UINT checkState) |
97 | { return BOOLToBool(CheckDlgButton(_window, buttonID, checkState)); } | 98 | { return BOOLToBool(CheckDlgButton(_window, (int)buttonID, checkState)); } |
98 | bool CheckButton(int buttonID, bool checkState) | 99 | bool CheckButton(unsigned buttonID, bool checkState) |
99 | { return CheckButton(buttonID, UINT(checkState ? BST_CHECKED : BST_UNCHECKED)); } | 100 | { return CheckButton(buttonID, UINT(checkState ? BST_CHECKED : BST_UNCHECKED)); } |
100 | 101 | ||
101 | UINT IsButtonChecked(int buttonID) const | 102 | UINT IsButtonChecked_BST(unsigned buttonID) const |
102 | { return IsDlgButtonChecked(_window, buttonID); } | 103 | { return IsDlgButtonChecked(_window, (int)buttonID); } |
103 | bool IsButtonCheckedBool(int buttonID) const | 104 | bool IsButtonCheckedBool(unsigned buttonID) const |
104 | { return (IsButtonChecked(buttonID) == BST_CHECKED); } | 105 | { return (IsButtonChecked_BST(buttonID) == BST_CHECKED); } |
105 | 106 | ||
106 | bool CheckRadioButton(int firstButtonID, int lastButtonID, int checkButtonID) | 107 | bool CheckRadioButton(unsigned firstButtonID, unsigned lastButtonID, unsigned checkButtonID) |
107 | { return BOOLToBool(::CheckRadioButton(_window, firstButtonID, lastButtonID, checkButtonID)); } | 108 | { return BOOLToBool(::CheckRadioButton(_window, |
109 | (int)firstButtonID, (int)lastButtonID, (int)checkButtonID)); } | ||
108 | 110 | ||
109 | virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam); | 111 | virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam); |
110 | virtual bool OnInit() { return true; } | 112 | virtual bool OnInit() { return true; } |
111 | virtual bool OnCommand(WPARAM wParam, LPARAM lParam); | 113 | // virtual bool OnCommand2(WPARAM wParam, LPARAM lParam); |
112 | virtual bool OnCommand(int code, int itemID, LPARAM lParam); | 114 | virtual bool OnCommand(unsigned code, unsigned itemID, LPARAM lParam); |
113 | virtual bool OnSize(WPARAM /* wParam */, int /* xSize */, int /* ySize */) { return false; } | 115 | virtual bool OnSize(WPARAM /* wParam */, int /* xSize */, int /* ySize */) { return false; } |
114 | virtual bool OnDestroy() { return false; } | 116 | virtual bool OnDestroy() { return false; } |
115 | 117 | ||
@@ -120,11 +122,11 @@ public: | |||
120 | virtual void OnHelp(LPHELPINFO) { OnHelp(); } | 122 | virtual void OnHelp(LPHELPINFO) { OnHelp(); } |
121 | #endif | 123 | #endif |
122 | */ | 124 | */ |
123 | virtual void OnHelp() {}; | 125 | virtual void OnHelp() {} |
124 | 126 | ||
125 | virtual bool OnButtonClicked(int buttonID, HWND buttonHWND); | 127 | virtual bool OnButtonClicked(unsigned buttonID, HWND buttonHWND); |
126 | virtual void OnOK() {}; | 128 | virtual void OnOK() {} |
127 | virtual void OnCancel() {}; | 129 | virtual void OnCancel() {} |
128 | virtual void OnClose() {} | 130 | virtual void OnClose() {} |
129 | virtual bool OnNotify(UINT /* controlID */, LPNMHDR /* lParam */) { return false; } | 131 | virtual bool OnNotify(UINT /* controlID */, LPNMHDR /* lParam */) { return false; } |
130 | virtual bool OnTimer(WPARAM /* timerID */, LPARAM /* callback */) { return false; } | 132 | virtual bool OnTimer(WPARAM /* timerID */, LPARAM /* callback */) { return false; } |
@@ -136,9 +138,11 @@ public: | |||
136 | 138 | ||
137 | bool GetMargins(int margin, int &x, int &y); | 139 | bool GetMargins(int margin, int &x, int &y); |
138 | int Units_To_Pixels_X(int units); | 140 | int Units_To_Pixels_X(int units); |
139 | bool GetItemSizes(int id, int &x, int &y); | 141 | bool GetItemSizes(unsigned id, int &x, int &y); |
140 | void GetClientRectOfItem(int id, RECT &rect); | 142 | void GetClientRectOfItem(unsigned id, RECT &rect); |
141 | bool MoveItem(int id, int x, int y, int width, int height, bool repaint = true); | 143 | bool MoveItem(unsigned id, int x, int y, int width, int height, bool repaint = true); |
144 | bool MoveItem_RECT(unsigned id, const RECT &r, bool repaint = true) | ||
145 | { return MoveItem(id, r.left, r.top, RECT_SIZE_X(r), RECT_SIZE_Y(r), repaint); } | ||
142 | 146 | ||
143 | void NormalizeSize(bool fullNormalize = false); | 147 | void NormalizeSize(bool fullNormalize = false); |
144 | void NormalizePosition(); | 148 | void NormalizePosition(); |
@@ -152,9 +156,9 @@ public: | |||
152 | #ifndef _UNICODE | 156 | #ifndef _UNICODE |
153 | bool Create(LPCWSTR templateName, HWND parentWindow); | 157 | bool Create(LPCWSTR templateName, HWND parentWindow); |
154 | #endif | 158 | #endif |
155 | virtual void OnOK() { Destroy(); } | 159 | virtual void OnOK() Z7_override { Destroy(); } |
156 | virtual void OnCancel() { Destroy(); } | 160 | virtual void OnCancel() Z7_override { Destroy(); } |
157 | virtual void OnClose() { Destroy(); } | 161 | virtual void OnClose() Z7_override { Destroy(); } |
158 | }; | 162 | }; |
159 | 163 | ||
160 | class CModalDialog: public CDialog | 164 | class CModalDialog: public CDialog |
@@ -167,18 +171,18 @@ public: | |||
167 | #endif | 171 | #endif |
168 | 172 | ||
169 | bool End(INT_PTR result) { return BOOLToBool(::EndDialog(_window, result)); } | 173 | bool End(INT_PTR result) { return BOOLToBool(::EndDialog(_window, result)); } |
170 | virtual void OnOK() { End(IDOK); } | 174 | virtual void OnOK() Z7_override { End(IDOK); } |
171 | virtual void OnCancel() { End(IDCANCEL); } | 175 | virtual void OnCancel() Z7_override { End(IDCANCEL); } |
172 | virtual void OnClose() { End(IDCLOSE); } | 176 | virtual void OnClose() Z7_override { End(IDCLOSE); } |
173 | }; | 177 | }; |
174 | 178 | ||
175 | class CDialogChildControl: public NWindows::CWindow | 179 | class CDialogChildControl: public NWindows::CWindow |
176 | { | 180 | { |
177 | int m_ID; | 181 | // unsigned m_ID; |
178 | public: | 182 | public: |
179 | void Init(const NWindows::NControl::CDialog &parentDialog, int id) | 183 | void Init(const NWindows::NControl::CDialog &parentDialog, unsigned id) |
180 | { | 184 | { |
181 | m_ID = id; | 185 | // m_ID = id; |
182 | Attach(parentDialog.GetItem(id)); | 186 | Attach(parentDialog.GetItem(id)); |
183 | } | 187 | } |
184 | }; | 188 | }; |