From 2fa4d8fd0f2c29517025dfc3bebc8a5e07c3d380 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 13 Apr 2015 14:39:35 +0000 Subject: - nasty crutch removed from Options_AddPage; - HWND hwndParent removed from the CDlgBase constructor; - method CDlgBase::SetParent() added for the rare occasions where it's needed; git-svn-id: http://svn.miranda-ng.org/main/trunk@12785 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- include/m_gui.h | 36 +++++++++--------------------------- include/m_options.h | 5 ++++- 2 files changed, 13 insertions(+), 28 deletions(-) (limited to 'include') diff --git a/include/m_gui.h b/include/m_gui.h index cf8fc3844f..b71ae87ca2 100644 --- a/include/m_gui.h +++ b/include/m_gui.h @@ -259,7 +259,7 @@ class MIR_CORE_EXPORT CDlgBase friend class CCtrlData; public: - CDlgBase(HINSTANCE hInst, int idDialog, HWND hwndParent); + CDlgBase(HINSTANCE hInst, int idDialog); virtual ~CDlgBase(); // general utilities @@ -267,29 +267,11 @@ public: void Show(int nCmdShow = SW_SHOW); int DoModal(); - __inline HWND GetHwnd() const { return m_hwnd; } - __inline bool IsInitialized() const { return m_initialized; } - __inline void Close() { SendMessage(m_hwnd, WM_CLOSE, 0, 0); } - __inline const MSG *ActiveMessage() const { return &m_msg; } - - // dynamic creation support (mainly to avoid leaks in options) - struct CreateParam - { - CDlgBase *(*create)(void *param); - void *param; - }; - static INT_PTR CALLBACK DynamicDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) - { - if (msg == WM_INITDIALOG) - { - CreateParam *param = (CreateParam *)lParam; - CDlgBase *wnd = param->create(param->param); - SetWindowLongPtr(hwnd, DWLP_DLGPROC, (LONG_PTR)GlobalDlgProc); - return GlobalDlgProc(hwnd, msg, wParam, (LPARAM)wnd); - } - - return FALSE; - } + __forceinline HWND GetHwnd() const { return m_hwnd; } + __forceinline bool IsInitialized() const { return m_initialized; } + __forceinline void SetParent(HWND hwnd) { m_hwndParent = hwnd; } + __forceinline void Close() { SendMessage(m_hwnd, WM_CLOSE, 0, 0); } + __forceinline const MSG *ActiveMessage() const { return &m_msg; } LRESULT m_lresult; @@ -1205,7 +1187,7 @@ class MIR_CORE_EXPORT CProtoIntDlgBase : public CDlgBase typedef CDlgBase CSuper; public: - CProtoIntDlgBase(PROTO_INTERFACE *proto, int idDialog, HWND parent, bool show_label = true); + CProtoIntDlgBase(PROTO_INTERFACE *proto, int idDialog, bool show_label = true); void CreateLink(CCtrlData& ctrl, char *szSetting, BYTE type, DWORD iValue); void CreateLink(CCtrlData& ctrl, const char *szSetting, TCHAR *szValue); @@ -1242,8 +1224,8 @@ class CProtoDlgBase : public CProtoIntDlgBase typedef CProtoIntDlgBase CSuper; public: - __inline CProtoDlgBase(TProto *proto, int idDialog, HWND parent, bool show_label=true) : - CProtoIntDlgBase(proto, idDialog, parent, show_label), + __inline CProtoDlgBase(TProto *proto, int idDialog, bool show_label=true) : + CProtoIntDlgBase(proto, idDialog, show_label), m_proto(proto) { } diff --git a/include/m_options.h b/include/m_options.h index fd6f7bd47c..1deed0242b 100644 --- a/include/m_options.h +++ b/include/m_options.h @@ -80,7 +80,10 @@ typedef struct { TCHAR* ptszTab; //v0.6.0.0+ }; - LPARAM dwInitParam; //v0.8.0.0+ a value to pass to lParam of WM_INITDIALOG message + union { + LPARAM dwInitParam; //v0.8.0.0+ a value to pass to lParam of WM_INITDIALOG message + class CDlgBase *pDialog; + }; int hLangpack; } OPTIONSDIALOGPAGE; -- cgit v1.2.3