summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-07-11 17:09:17 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-07-11 17:09:17 +0300
commitb2c91edc9646daa331de71d589e4fec6bdef4945 (patch)
tree847a77d0686d26e25b126313fbaa8262c81f8d1a /include
parentae081843e9663b3cb36b17309fbce1d2967315f1 (diff)
GUI change:
- methods OnInitDialog, OnApply & OnClose of CDlgBase now return true if successful. return of false prevents a dialog from being loaded or left respectively; - massive code cleaning considering the 'virtual' attribute of overridden methods; - also fixes #1476 (Don't close "Create new account" window if user not set account name)
Diffstat (limited to 'include')
-rw-r--r--include/m_chat_int.h6
-rw-r--r--include/m_gui.h41
2 files changed, 23 insertions, 24 deletions
diff --git a/include/m_chat_int.h b/include/m_chat_int.h
index 5ad09897a2..033d5d36da 100644
--- a/include/m_chat_int.h
+++ b/include/m_chat_int.h
@@ -405,10 +405,10 @@ class MIR_APP_EXPORT CSrmmBaseDialog : public CDlgBase
protected:
CSrmmBaseDialog(CMPluginBase&, int idDialog, SESSION_INFO *si = nullptr);
- virtual void OnInitDialog() override;
- virtual void OnDestroy() override;
+ bool OnInitDialog() override;
+ void OnDestroy() override;
- virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
+ INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
int NotifyEvent(int code);
bool ProcessHotkeys(int key, bool bShift, bool bCtrl, bool bAlt);
diff --git a/include/m_gui.h b/include/m_gui.h
index bdabf4d323..98b09786ee 100644
--- a/include/m_gui.h
+++ b/include/m_gui.h
@@ -412,7 +412,6 @@ public:
void SetCaption(const wchar_t *ptszCaption);
void NotifyChange(void); // sends a notification to a parent window
- __forceinline void Fail() { m_lresult = false; }
__forceinline HINSTANCE GetInst() const { return m_pPlugin.getInst(); }
__forceinline HWND GetHwnd() const { return m_hwnd; }
__forceinline void Hide() { Show(SW_HIDE); }
@@ -424,14 +423,13 @@ public:
static CDlgBase* Find(HWND hwnd);
protected:
- HWND m_hwnd; // must be the first data item
- HWND m_hwndParent;
+ HWND m_hwnd = nullptr; // must be the first data item
+ HWND m_hwndParent = nullptr;
int m_idDialog;
- bool m_isModal;
- bool m_initialized;
- bool m_forceResizable;
- bool m_bExiting; // window received WM_CLOSE and gonna die soon
- LRESULT m_lresult;
+ bool m_isModal = false;
+ bool m_initialized = false;
+ bool m_forceResizable = false;
+ bool m_bExiting = false; // window received WM_CLOSE and gonna die soon
CMPluginBase &m_pPlugin;
@@ -440,17 +438,17 @@ protected:
// override this handlers to provide custom functionality
// general messages
- virtual void OnInitDialog() { }
- virtual void OnClose() { }
- virtual void OnDestroy() { }
+ virtual bool OnInitDialog();
+ virtual bool OnApply();
+ virtual bool OnClose();
+ virtual void OnDestroy();
- virtual void OnTimer(CTimer*) {}
+ virtual void OnTimer(CTimer*);
// miranda-related stuff
virtual int Resizer(UTILRESIZECONTROL *urc);
- virtual void OnApply() {}
- virtual void OnReset() {}
- virtual void OnChange() {}
+ virtual void OnReset();
+ virtual void OnChange();
// main dialog procedure
virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam);
@@ -479,6 +477,7 @@ private:
LIST<CCtrlBase> m_controls;
void NotifyControls(void (CCtrlBase::*fn)());
+ bool VerifyControls(bool (CCtrlBase::*fn)());
CTimer* FindTimer(int idEvent);
@@ -567,7 +566,7 @@ public:
virtual void OnInit();
virtual void OnDestroy();
- virtual void OnApply();
+ virtual bool OnApply();
virtual void OnReset();
protected:
@@ -819,7 +818,7 @@ public:
CCtrlCheck(CDlgBase *dlg, int ctrlId);
BOOL OnCommand(HWND /*hwndCtrl*/, WORD /*idCtrl*/, WORD /*idCode*/) override;
- void OnApply() override;
+ bool OnApply() override;
void OnReset() override;
int GetState();
@@ -839,7 +838,7 @@ public:
CCtrlEdit(CDlgBase *dlg, int ctrlId);
BOOL OnCommand(HWND /*hwndCtrl*/, WORD /*idCtrl*/, WORD idCode) override;
- void OnApply() override;
+ bool OnApply() override;
void OnReset() override;
void SetMaxLength(unsigned int len);
@@ -882,7 +881,7 @@ class MIR_CORE_EXPORT CCtrlSpin : public CCtrlData
public:
CCtrlSpin(CDlgBase *dlg, int ctrlId);
- void OnApply() override;
+ bool OnApply() override;
void OnReset() override;
WORD GetPosition();
@@ -942,7 +941,7 @@ public:
BOOL OnCommand(HWND /*hwndCtrl*/, WORD /*idCtrl*/, WORD idCode) override;
void OnInit() override;
- void OnApply() override;
+ bool OnApply() override;
void OnReset() override;
// Control interface
@@ -1354,7 +1353,7 @@ protected:
void OnInit() override;
void OnDestroy() override;
- void OnApply() override;
+ bool OnApply() override;
void OnReset() override;
LRESULT CustomWndProc(UINT msg, WPARAM wParam, LPARAM lParam) override;