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 --- bin10/lib/mir_core.lib | Bin 327650 -> 327502 bytes bin10/lib/mir_core64.lib | Bin 329388 -> 329222 bytes bin12/lib/mir_core.lib | Bin 327650 -> 327502 bytes bin12/lib/mir_core64.lib | Bin 329388 -> 329222 bytes include/m_gui.h | 36 +++--------- include/m_options.h | 5 +- protocols/IRCG/src/irc.h | 2 - protocols/IRCG/src/irc_dlg.h | 10 +--- protocols/IRCG/src/options.cpp | 46 +++++++--------- protocols/IRCG/src/windows.cpp | 14 +++-- protocols/JabberG/src/jabber.h | 4 +- protocols/JabberG/src/jabber_agent.cpp | 5 +- protocols/JabberG/src/jabber_opt.cpp | 41 +++++--------- protocols/JabberG/src/jabber_privacy.cpp | 8 ++- protocols/JabberG/src/jabber_proto.h | 7 +-- protocols/JabberG/src/jabber_svc.cpp | 4 +- protocols/Tox/src/tox_options.cpp | 45 ++++++--------- protocols/Tox/src/tox_options.h | 8 +-- protocols/Tox/src/tox_profile.cpp | 2 +- protocols/Tox/src/tox_proto.h | 3 - protocols/Tox/src/tox_search.cpp | 4 +- src/core/commonheaders.h | 1 + src/mir_core/src/mir_core.def | 6 +- src/mir_core/src/mir_core64.def | 7 ++- src/mir_core/src/ui_utils.cpp | 8 +-- src/modules/options/options.cpp | 92 ++++++++++++++++--------------- 26 files changed, 152 insertions(+), 206 deletions(-) diff --git a/bin10/lib/mir_core.lib b/bin10/lib/mir_core.lib index 716d9b09ef..006178cbe7 100644 Binary files a/bin10/lib/mir_core.lib and b/bin10/lib/mir_core.lib differ diff --git a/bin10/lib/mir_core64.lib b/bin10/lib/mir_core64.lib index 47094a57cf..bfa4ae4fc4 100644 Binary files a/bin10/lib/mir_core64.lib and b/bin10/lib/mir_core64.lib differ diff --git a/bin12/lib/mir_core.lib b/bin12/lib/mir_core.lib index 14d462c348..006178cbe7 100644 Binary files a/bin12/lib/mir_core.lib and b/bin12/lib/mir_core.lib differ diff --git a/bin12/lib/mir_core64.lib b/bin12/lib/mir_core64.lib index 7c3d102e79..bfa4ae4fc4 100644 Binary files a/bin12/lib/mir_core64.lib and b/bin12/lib/mir_core64.lib differ 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; diff --git a/protocols/IRCG/src/irc.h b/protocols/IRCG/src/irc.h index a666514a85..c937c2f620 100644 --- a/protocols/IRCG/src/irc.h +++ b/protocols/IRCG/src/irc.h @@ -363,8 +363,6 @@ struct CIrcProto : public PROTO CMStringA sChannelModes, sUserModes; CMString sChannelPrefixes, sUserModePrefixes, WhoisAwayReply; - CDlgBase::CreateParam OptCreateAccount, OptCreateConn, OptCreateIgnore, OptCreateOther; - //clist.cpp MCONTACT CList_AddContact(CONTACT *user, bool InList, bool SetOnline); bool CList_SetAllOffline(BYTE ChatsToo); diff --git a/protocols/IRCG/src/irc_dlg.h b/protocols/IRCG/src/irc_dlg.h index 9414365e3b..327130838f 100644 --- a/protocols/IRCG/src/irc_dlg.h +++ b/protocols/IRCG/src/irc_dlg.h @@ -34,7 +34,7 @@ struct CMessageBoxDlg : public CProtoDlgBase < CIrcProto > struct CCoolIrcDlg : public CProtoDlgBase < CIrcProto > { - CCoolIrcDlg(CIrcProto* _pro, int dlgId, HWND parent = NULL); + CCoolIrcDlg(CIrcProto* _pro, int dlgId); virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam); @@ -208,8 +208,6 @@ struct CConnectPrefsDlg : public CProtoDlgBase < CIrcProto > CConnectPrefsDlg(CIrcProto* _pro); - static CDlgBase* Create(void* param) { return new CConnectPrefsDlg((CIrcProto*)param); } - virtual void OnInitDialog(); virtual void OnApply(); @@ -236,8 +234,6 @@ struct CCtcpPrefsDlg : public CProtoDlgBase < CIrcProto > CCtcpPrefsDlg(CIrcProto* _pro); - static CDlgBase* Create(void* param) { return new CCtcpPrefsDlg((CIrcProto*)param); } - virtual void OnInitDialog(); virtual void OnApply(); @@ -258,8 +254,6 @@ struct COtherPrefsDlg : public CProtoDlgBase < CIrcProto > COtherPrefsDlg(CIrcProto* _pro); - static CDlgBase* Create(void* param) { return new COtherPrefsDlg((CIrcProto*)param); } - virtual void OnInitDialog(); virtual void OnApply(); virtual void OnDestroy(); @@ -285,8 +279,6 @@ struct CIgnorePrefsDlg : public CProtoDlgBase < CIrcProto > CIgnorePrefsDlg(CIrcProto* _pro); - static CDlgBase* Create(void* param) { return new CIgnorePrefsDlg((CIrcProto*)param); } - virtual void OnInitDialog(); virtual void OnDestroy(); virtual void OnApply(); diff --git a/protocols/IRCG/src/options.cpp b/protocols/IRCG/src/options.cpp index f98fcc1455..21f13227e5 100644 --- a/protocols/IRCG/src/options.cpp +++ b/protocols/IRCG/src/options.cpp @@ -306,7 +306,7 @@ struct CServerDlg : public CProtoDlgBase CCtrlCombo m_groupCombo; CServerDlg(CIrcProto* _pro, CConnectPrefsDlg* _owner, int _action) - : CProtoDlgBase(_pro, IDD_ADDSERVER, _owner->GetHwnd(), false), + : CProtoDlgBase(_pro, IDD_ADDSERVER, false), m_owner(_owner), m_action(_action), m_OK(this, IDOK), @@ -316,6 +316,7 @@ struct CServerDlg : public CProtoDlgBase m_port(this, IDC_ADD_PORT), m_port2(this, IDC_ADD_PORT2) { + m_hwndParent = _owner->GetHwnd(); m_OK.OnClick = Callback(this, &CServerDlg::OnOk); m_autoClose = CLOSE_ON_CANCEL; } @@ -450,7 +451,7 @@ static TDbSetting ConnectSettings[] = }; CConnectPrefsDlg::CConnectPrefsDlg(CIrcProto* _pro) - : CProtoDlgBase(_pro, IDD_PREFS_CONNECT, NULL, false), + : CProtoDlgBase(_pro, IDD_PREFS_CONNECT, false), m_serverCombo(this, IDC_SERVERCOMBO), m_server(this, IDC_SERVER), m_port(this, IDC_PORT), @@ -812,7 +813,7 @@ static TDbSetting CtcpSettings[] = }; CCtcpPrefsDlg::CCtcpPrefsDlg(CIrcProto* _pro) - : CProtoDlgBase(_pro, IDD_PREFS_CTCP, NULL, false), + : CProtoDlgBase(_pro, IDD_PREFS_CTCP, false), m_enableIP(this, IDC_ENABLEIP), m_fromServer(this, IDC_FROMSERVER), m_combo(this, IDC_COMBO), @@ -991,7 +992,7 @@ static LRESULT CALLBACK EditSubclassProc(HWND hwndDlg, UINT msg, WPARAM wParam, } COtherPrefsDlg::COtherPrefsDlg(CIrcProto* _pro) - : CProtoDlgBase(_pro, IDD_PREFS_OTHER, NULL, false), + : CProtoDlgBase(_pro, IDD_PREFS_OTHER, false), m_url(this, IDC_CUSTOM), m_performCombo(this, IDC_PERFORMCOMBO), m_codepage(this, IDC_CODEPAGE), @@ -1208,10 +1209,12 @@ void COtherPrefsDlg::addPerformComboValue(int idx, const char* szValueName) // 'add ignore' preferences dialog CAddIgnoreDlg::CAddIgnoreDlg(CIrcProto* _pro, const TCHAR* mask, CIgnorePrefsDlg* _owner) - : CProtoDlgBase(_pro, IDD_ADDIGNORE, _owner->GetHwnd(), false), + : CProtoDlgBase(_pro, IDD_ADDIGNORE, false), m_Ok(this, IDOK), m_owner(_owner) { + m_hwndParent = _owner->GetHwnd(); + if (mask == NULL) szOldMask[0] = 0; else @@ -1407,7 +1410,7 @@ void CIrcProto::RewriteIgnoreSettings(void) } CIgnorePrefsDlg::CIgnorePrefsDlg(CIrcProto* _pro) - : CProtoDlgBase(_pro, IDD_PREFS_IGNORE, NULL, false), + : CProtoDlgBase(_pro, IDD_PREFS_IGNORE, false), m_list(this, IDC_LIST), m_add(this, IDC_ADD, LoadIconEx(IDI_ADD), LPGEN("Add new ignore")), m_edit(this, IDC_EDIT, LoadIconEx(IDI_EDIT), LPGEN("Edit this ignore")), @@ -1654,38 +1657,26 @@ void CIgnorePrefsDlg::UpdateList() int CIrcProto::OnInitOptionsPages(WPARAM wParam, LPARAM) { - OPTIONSDIALOGPAGE odp = { sizeof(odp) }; - odp.hInstance = hInst; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_PREFS_CONNECT); + OPTIONSDIALOGPAGE odp = { 0 }; + odp.cbSize = sizeof(odp); odp.ptszTitle = m_tszUserName; odp.ptszGroup = LPGENT("Network"); - odp.ptszTab = LPGENT("Account"); odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR | ODPF_DONTTRANSLATE; - odp.pfnDlgProc = CDlgBase::DynamicDlgProc; - odp.dwInitParam = (LPARAM)&OptCreateAccount; - OptCreateAccount.create = CConnectPrefsDlg::Create; - OptCreateAccount.param = this; + + odp.ptszTab = LPGENT("Account"); + odp.pDialog = new CConnectPrefsDlg(this); Options_AddPage(wParam, &odp); - odp.pszTemplate = MAKEINTRESOURCEA(IDD_PREFS_CTCP); odp.ptszTab = LPGENT("DCC and CTCP"); - odp.dwInitParam = (LPARAM)&OptCreateConn; - OptCreateConn.create = CCtcpPrefsDlg::Create; - OptCreateConn.param = this; + odp.pDialog = new CCtcpPrefsDlg(this); Options_AddPage(wParam, &odp); - odp.pszTemplate = MAKEINTRESOURCEA(IDD_PREFS_OTHER); odp.ptszTab = LPGENT("Advanced"); - odp.dwInitParam = (LPARAM)&OptCreateOther; - OptCreateOther.create = COtherPrefsDlg::Create; - OptCreateOther.param = this; + odp.pDialog = new COtherPrefsDlg(this); Options_AddPage(wParam, &odp); - odp.pszTemplate = MAKEINTRESOURCEA(IDD_PREFS_IGNORE); odp.ptszTab = LPGENT("Ignore"); - odp.dwInitParam = (LPARAM)&OptCreateIgnore; - OptCreateIgnore.create = CIgnorePrefsDlg::Create; - OptCreateIgnore.param = this; + odp.pDialog = new CIgnorePrefsDlg(this); Options_AddPage(wParam, &odp); return 0; } @@ -1765,7 +1756,7 @@ struct CDlgAccMgrUI : public CProtoDlgBase CCtrlEdit m_server, m_port, m_port2, m_pass, m_nick, m_nick2, m_name, m_userID, m_ssl; CDlgAccMgrUI(CIrcProto* _pro, HWND _owner) - : CProtoDlgBase(_pro, IDD_ACCMGRUI, _owner, false), + : CProtoDlgBase(_pro, IDD_ACCMGRUI, false), m_serverCombo(this, IDC_SERVERCOMBO), m_server(this, IDC_SERVER), m_port(this, IDC_PORT), @@ -1777,6 +1768,7 @@ struct CDlgAccMgrUI : public CProtoDlgBase m_ssl(this, IDC_SSL), m_userID(this, IDC_USERID) { + m_hwndParent = _owner; m_serverCombo.OnChange = Callback(this, &CDlgAccMgrUI::OnChangeCombo); } diff --git a/protocols/IRCG/src/windows.cpp b/protocols/IRCG/src/windows.cpp index a35a571855..dc6e686b3e 100644 --- a/protocols/IRCG/src/windows.cpp +++ b/protocols/IRCG/src/windows.cpp @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Message Box CMessageBoxDlg::CMessageBoxDlg(CIrcProto *_pro, DCCINFO *_dci) - : CProtoDlgBase(_pro, IDD_MESSAGEBOX, NULL, false), + : CProtoDlgBase(_pro, IDD_MESSAGEBOX, false), pdci(_dci), m_Ok(this, IDOK) { @@ -251,7 +251,7 @@ void CNickDlg::OnOk(CCtrlButton*) #define LIST_TIMER 10 CListDlg::CListDlg(CIrcProto *_pro) - : CProtoDlgBase(_pro, IDD_LIST, NULL, false), + : CProtoDlgBase(_pro, IDD_LIST, false), m_Join(this, IDC_JOIN), m_list(this, IDC_INFO_LISTVIEW), m_list2(this, IDC_INFO_LISTVIEW2), @@ -492,7 +492,7 @@ void CListDlg::UpdateList() // 'Join' dialog CJoinDlg::CJoinDlg(CIrcProto *_pro) - : CCoolIrcDlg(_pro, IDD_NICK, NULL), + : CCoolIrcDlg(_pro, IDD_NICK), m_Ok(this, IDOK) { m_Ok.OnClick = Callback(this, &CJoinDlg::OnOk); @@ -701,10 +701,12 @@ void CQuickDlg::OnServerCombo(CCtrlData*) // 'Question' dialog CQuestionDlg::CQuestionDlg(CIrcProto *_pro, CManagerDlg *owner) - : CCoolIrcDlg(_pro, IDD_QUESTION, (owner == NULL) ? NULL : owner->GetHwnd()), + : CCoolIrcDlg(_pro, IDD_QUESTION), m_Ok(this, IDOK), m_owner(owner) { + if (owner != NULL) + m_hwndParent = owner->GetHwnd(); m_Ok.OnClick = Callback(this, &CQuestionDlg::OnOk); } @@ -1369,8 +1371,8 @@ void CManagerDlg::InitManager(int mode, const TCHAR* window) ///////////////////////////////////////////////////////////////////////////////////////// // 'cool' dialog -CCoolIrcDlg::CCoolIrcDlg(CIrcProto* _pro, int dlgId, HWND parent) - : CProtoDlgBase(_pro, dlgId, parent, false) +CCoolIrcDlg::CCoolIrcDlg(CIrcProto* _pro, int dlgId) + : CProtoDlgBase(_pro, dlgId, false) {} void CCoolIrcDlg::OnInitDialog() diff --git a/protocols/JabberG/src/jabber.h b/protocols/JabberG/src/jabber.h index dd707ac2be..09448a9446 100644 --- a/protocols/JabberG/src/jabber.h +++ b/protocols/JabberG/src/jabber.h @@ -124,8 +124,8 @@ class CJabberDlgBase : public CProtoDlgBase { typedef CProtoDlgBase CSuper; protected: - __inline CJabberDlgBase(CJabberProto *proto, int idDialog, HWND parent, bool show_label=true) : - CSuper(proto, idDialog, parent, show_label) + __inline CJabberDlgBase(CJabberProto *proto, int idDialog, bool show_label=true) : + CSuper(proto, idDialog, show_label) { } diff --git a/protocols/JabberG/src/jabber_agent.cpp b/protocols/JabberG/src/jabber_agent.cpp index 5b6176bf86..88487f68ba 100644 --- a/protocols/JabberG/src/jabber_agent.cpp +++ b/protocols/JabberG/src/jabber_agent.cpp @@ -35,9 +35,10 @@ class CAgentRegProgressDlg : public CJabberDlgBase public: CAgentRegProgressDlg(CJabberProto *_ppro, HWND _owner) : - CJabberDlgBase(_ppro, IDD_OPT_REGISTER, _owner, false), + CJabberDlgBase(_ppro, IDD_OPT_REGISTER, false), m_ok(this, IDOK) { + SetParent(_owner); m_ok.OnClick = Callback(this, &CAgentRegProgressDlg::OnOk); } @@ -87,7 +88,7 @@ class CAgentRegDlg : public CJabberDlgBase public: CAgentRegDlg(CJabberProto *_ppro, TCHAR *_jid) : - CJabberDlgBase(_ppro, IDD_FORM, NULL, false), + CJabberDlgBase(_ppro, IDD_FORM, false), m_submit(this, IDC_SUBMIT), m_jid(_jid), m_agentRegIqNode(NULL) diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp index 61190c27d7..f935c44fdf 100644 --- a/protocols/JabberG/src/jabber_opt.cpp +++ b/protocols/JabberG/src/jabber_opt.cpp @@ -229,11 +229,12 @@ class CJabberDlgRegister: public CJabberDlgBase typedef CJabberDlgBase CSuper; public: CJabberDlgRegister(CJabberProto *proto, HWND hwndParent, JABBER_CONN_DATA *regInfo): - CJabberDlgBase(proto, IDD_OPT_REGISTER, hwndParent, false), + CJabberDlgBase(proto, IDD_OPT_REGISTER, false), m_bProcessStarted(false), m_regInfo(regInfo), m_btnOk(this, IDOK) { + SetParent(hwndParent); m_autoClose = CLOSE_ON_CANCEL; m_btnOk.OnClick = Callback(this, &CJabberDlgRegister::btnOk_OnClick); } @@ -364,7 +365,7 @@ class CDlgOptAccount: public CJabberDlgBase public: CDlgOptAccount(CJabberProto *proto): - CJabberDlgBase(proto, IDD_OPT_JABBER, NULL, false), + CJabberDlgBase(proto, IDD_OPT_JABBER, false), m_txtUsername(this, IDC_EDIT_USERNAME), m_txtPassword(this, IDC_EDIT_PASSWORD), m_txtPriority(this, IDC_PRIORITY), @@ -419,8 +420,6 @@ public: m_btnChangePassword.OnClick = Callback(this, &CDlgOptAccount::btnChangePassword_OnClick); } - static CDlgBase *Create(void *param) { return new CDlgOptAccount((CJabberProto *)param); } - protected: void OnInitDialog() { @@ -774,7 +773,7 @@ class CDlgOptAdvanced: public CJabberDlgBase public: CDlgOptAdvanced(CJabberProto *proto): - CJabberDlgBase(proto, IDD_OPT_JABBER2, NULL, false), + CJabberDlgBase(proto, IDD_OPT_JABBER2, false), m_chkDirect(this, IDC_DIRECT), m_chkDirectManual(this, IDC_DIRECT_MANUAL), m_chkProxy(this, IDC_PROXY_MANUAL), @@ -875,8 +874,6 @@ public: else m_txtProxy.Disable(); } - - static CDlgBase *Create(void *param) { return new CDlgOptAdvanced((CJabberProto *)param); } }; ///////////////////////////////////////////////////////////////////////////////////////// @@ -893,7 +890,7 @@ class CDlgOptGc: public CJabberDlgBase public: CDlgOptGc(CJabberProto *proto): - CJabberDlgBase(proto, IDD_OPT_JABBER4, NULL, false), + CJabberDlgBase(proto, IDD_OPT_JABBER4, false), m_txtAltNick(this, IDC_TXT_ALTNICK), m_txtSlap(this, IDC_TXT_SLAP), m_txtQuit(this, IDC_TXT_QUIT), @@ -915,8 +912,6 @@ public: m_otvOptions.AddOption(LPGENT("Log events") _T("/") LPGENT("Status changes"), m_proto->m_options.GcLogStatuses); m_otvOptions.AddOption(LPGENT("Log events") _T("/") LPGENT("Don't notify history messages"), m_proto->m_options.GcLogChatHistory); } - - static CDlgBase *Create(void *param) { return new CDlgOptGc((CJabberProto *)param); } }; ////////////////////////////////////////////////////////////////////////// @@ -1511,34 +1506,22 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleRosterControl(WPARAM, LPARAM) int CJabberProto::OnOptionsInit(WPARAM wParam, LPARAM) { - OPTIONSDIALOGPAGE odp = { sizeof(odp) }; - odp.hInstance = hInst; + OPTIONSDIALOGPAGE odp = { 0 }; + odp.cbSize = sizeof(odp); odp.ptszGroup = LPGENT("Network"); odp.ptszTitle = m_tszUserName; odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR | ODPF_DONTTRANSLATE; odp.ptszTab = LPGENT("Account"); - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_JABBER); - odp.pfnDlgProc = CDlgBase::DynamicDlgProc; - odp.dwInitParam = (LPARAM)&OptCreateAccount; - OptCreateAccount.create = CDlgOptAccount::Create; - OptCreateAccount.param = this; + odp.pDialog = new CDlgOptAccount(this); Options_AddPage(wParam, &odp); odp.ptszTab = LPGENT("Conferences"); - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_JABBER4); - odp.pfnDlgProc = CDlgBase::DynamicDlgProc; - odp.dwInitParam = (LPARAM)&OptCreateGc; - OptCreateGc.create = CDlgOptGc::Create; - OptCreateGc.param = this; + odp.pDialog = new CDlgOptGc(this); Options_AddPage(wParam, &odp); odp.ptszTab = LPGENT("Advanced"); - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_JABBER2); - odp.pfnDlgProc = CDlgBase::DynamicDlgProc; - odp.dwInitParam = (LPARAM)&OptCreateAdvanced; - OptCreateAdvanced.create = CDlgOptAdvanced::Create; - OptCreateAdvanced.param = this; + odp.pDialog = new CDlgOptAdvanced(this); Options_AddPage(wParam, &odp); return 0; } @@ -1564,7 +1547,7 @@ class CJabberDlgAccMgrUI: public CJabberDlgBase public: CJabberDlgAccMgrUI(CJabberProto *proto, HWND hwndParent): - CJabberDlgBase(proto, IDD_ACCMGRUI, hwndParent, false), + CJabberDlgBase(proto, IDD_ACCMGRUI, false), m_cbType(this, IDC_CB_TYPE), m_txtUsername(this, IDC_EDIT_USERNAME), m_txtPassword(this, IDC_EDIT_PASSWORD), @@ -1577,6 +1560,8 @@ public: m_txtManualHost(this, IDC_HOST), m_btnRegister(this, IDC_BUTTON_REGISTER) { + SetParent(hwndParent); + CreateLink(m_txtUsername, "LoginName", _T("")); CreateLink(m_chkSavePassword, proto->m_options.SavePassword); CreateLink(m_cbResource, "Resource", _T("Miranda")); diff --git a/protocols/JabberG/src/jabber_privacy.cpp b/protocols/JabberG/src/jabber_privacy.cpp index 3a31b8de44..ffcf2945ef 100644 --- a/protocols/JabberG/src/jabber_privacy.cpp +++ b/protocols/JabberG/src/jabber_privacy.cpp @@ -301,11 +301,13 @@ public: TCHAR szLine[512]; CJabberDlgPrivacyAddList(CJabberProto *proto, HWND hwndParent): - CJabberDlgBase(proto, IDD_PRIVACY_ADD_LIST, hwndParent, false), + CJabberDlgBase(proto, IDD_PRIVACY_ADD_LIST, false), m_txtName(this, IDC_EDIT_NAME), m_btnOk(this, IDOK), m_btnCancel(this, IDCANCEL) { + SetParent(hwndParent); + m_btnOk.OnClick = Callback(this, &CJabberDlgPrivacyAddList::btnOk_OnClick); m_btnCancel.OnClick = Callback(this, &CJabberDlgPrivacyAddList::btnCancel_OnClick); } @@ -341,11 +343,13 @@ public: CPrivacyListRule *m_pRule; CJabberDlgPrivacyRule(CJabberProto *proto, HWND hwndParent, CPrivacyListRule *pRule): - CJabberDlgBase(proto, IDD_PRIVACY_RULE, hwndParent, false), + CJabberDlgBase(proto, IDD_PRIVACY_RULE, false), m_btnOk(this, IDOK), m_btnCancel(this, IDCANCEL), m_cbType(this, IDC_COMBO_TYPE) { + SetParent(hwndParent); + m_pRule = pRule; m_cbType.OnChange = Callback(this, &CJabberDlgPrivacyRule::cbType_OnChange); m_btnOk.OnClick = Callback(this, &CJabberDlgPrivacyRule::btnOk_OnClick); diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index d078c91343..2f4764c94b 100644 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -600,12 +600,7 @@ struct CJabberProto : public PROTO, public IJabberInterface void MsgPopup(MCONTACT hContact, const TCHAR *szMsg, const TCHAR *szTitle); //---- jabber_opt.cpp ---------------------------------------------------------------- - - CJabberDlgBase::CreateParam OptCreateAccount; - CJabberDlgBase::CreateParam OptCreateGc; - CJabberDlgBase::CreateParam OptCreateAdvanced; - - INT_PTR __cdecl OnMenuHandleRosterControl(WPARAM wParam, LPARAM lParam); + INT_PTR __cdecl OnMenuHandleRosterControl(WPARAM wParam, LPARAM lParam); void _RosterExportToFile(HWND hwndDlg); void _RosterImportFromFile(HWND hwndDlg); diff --git a/protocols/JabberG/src/jabber_svc.cpp b/protocols/JabberG/src/jabber_svc.cpp index dc71adceab..19d6d8c154 100644 --- a/protocols/JabberG/src/jabber_svc.cpp +++ b/protocols/JabberG/src/jabber_svc.cpp @@ -587,12 +587,14 @@ class CJabberDlgHttpAuth: public CJabberDlgBase public: CJabberDlgHttpAuth(CJabberProto *proto, HWND hwndParent, CJabberHttpAuthParams *pParams): - CSuper(proto, IDD_HTTP_AUTH, hwndParent, true), + CSuper(proto, IDD_HTTP_AUTH, true), m_txtInfo(this, IDC_EDIT_HTTP_AUTH_INFO), m_btnAuth(this, IDOK), m_btnDeny(this, IDCANCEL), m_pParams(pParams) { + SetParent(hwndParent); + m_btnAuth.OnClick = Callback(this, &CJabberDlgHttpAuth::btnAuth_OnClick); m_btnDeny.OnClick = Callback(this, &CJabberDlgHttpAuth::btnDeny_OnClick); } diff --git a/protocols/Tox/src/tox_options.cpp b/protocols/Tox/src/tox_options.cpp index 4e7fb3103e..25443fb59e 100644 --- a/protocols/Tox/src/tox_options.cpp +++ b/protocols/Tox/src/tox_options.cpp @@ -1,13 +1,15 @@ #include "common.h" CToxOptionsMain::CToxOptionsMain(CToxProto *proto, int idDialog, HWND hwndParent) - : CToxDlgBase(proto, idDialog, hwndParent, false), + : CToxDlgBase(proto, idDialog, false), m_toxAddress(this, IDC_TOXID), m_toxAddressCopy(this, IDC_CLIPBOARD), m_profileCreate(this, IDC_PROFILE_NEW), m_profileImport(this, IDC_PROFILE_IMPORT), m_profileExport(this, IDC_PROFILE_EXPORT), m_nickname(this, IDC_NAME), m_password(this, IDC_PASSWORD), m_group(this, IDC_GROUP), m_enableUdp(this, IDC_ENABLE_UDP), m_enableIPv6(this, IDC_ENABLE_IPV6) { + SetParent(hwndParent); + CreateLink(m_toxAddress, TOX_SETTINGS_ID, _T("")); CreateLink(m_nickname, "Nick", _T("")); CreateLink(m_password, "Password", _T("")); @@ -52,7 +54,7 @@ void CToxOptionsMain::OnInitDialog() void CToxOptionsMain::ToxAddressCopy_OnClick(CCtrlButton*) { char *toxAddress = m_toxAddress.GetTextA(); - int toxAddressLength = mir_strlen(toxAddress) + 1; + size_t toxAddressLength = mir_strlen(toxAddress) + 1; if (OpenClipboard(m_toxAddress.GetHwnd())) { EmptyClipboard(); @@ -147,7 +149,7 @@ void CToxOptionsMain::OnApply() ///////////////////////////////////////////////////////////////////////////////// CToxNodeEditor::CToxNodeEditor(int iItem, CCtrlListView *m_nodes) - : CSuper(g_hInstance, IDD_NODE_EDITOR, NULL), + : CSuper(g_hInstance, IDD_NODE_EDITOR), m_ipv4(this, IDC_IPV4), m_ipv6(this, IDC_IPV6), m_port(this, IDC_PORT), m_pkey(this, IDC_PKEY), m_ok(this, IDOK), m_iItem(iItem) @@ -247,7 +249,7 @@ BOOL CCtrlNodeList::OnNotify(int idCtrl, NMHDR *pnmh) /****************************************/ CToxOptionsNodeList::CToxOptionsNodeList(CToxProto *proto) - : CSuper(proto, IDD_OPTIONS_NODES, NULL, false), + : CSuper(proto, IDD_OPTIONS_NODES, false), m_nodes(this, IDC_NODESLIST), m_addNode(this, IDC_ADDNODE) { m_addNode.OnClick = Callback(this, &CToxOptionsNodeList::OnAddNode); @@ -473,31 +475,18 @@ void CToxOptionsNodeList::OnApply() int CToxProto::OnOptionsInit(WPARAM wParam, LPARAM) { - char *title = mir_t2a(m_tszUserName); - - OPTIONSDIALOGPAGE odp = { sizeof(odp) }; - odp.hInstance = g_hInstance; - odp.pszTitle = title; - odp.flags = ODPF_BOLDGROUPS; - odp.pszGroup = LPGEN("Network"); - - odp.pszTab = LPGEN("Account"); - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS_MAIN); - odp.pfnDlgProc = CDlgBase::DynamicDlgProc; - odp.dwInitParam = (LPARAM)&ToxMainOptions; - ToxMainOptions.create = CToxOptionsMain::CreateOptionsPage; - ToxMainOptions.param = this; + OPTIONSDIALOGPAGE odp = { 0 }; + odp.cbSize = sizeof(odp); + odp.ptszTitle = m_tszUserName; + odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR; + odp.ptszGroup = LPGENT("Network"); + + odp.ptszTab = LPGENT("Account"); + odp.pDialog = new CToxOptionsMain(this, IDD_OPTIONS_MAIN); Options_AddPage(wParam, &odp); - odp.pszTab = LPGEN("Nodes"); - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS_NODES); - odp.pfnDlgProc = CDlgBase::DynamicDlgProc; - odp.dwInitParam = (LPARAM)&ToxNodeListOptions; - ToxNodeListOptions.create = CToxOptionsNodeList::CreateOptionsPage; - ToxNodeListOptions.param = this; + odp.ptszTab = LPGENT("Nodes"); + odp.pDialog = new CToxOptionsNodeList(this); Options_AddPage(wParam, &odp); - - mir_free(title); - return 0; -} \ No newline at end of file +} diff --git a/protocols/Tox/src/tox_options.h b/protocols/Tox/src/tox_options.h index 0b0e111513..afda3aee4e 100644 --- a/protocols/Tox/src/tox_options.h +++ b/protocols/Tox/src/tox_options.h @@ -38,8 +38,6 @@ public: page->Show(); return page; } - - static CDlgBase *CreateOptionsPage(void *param) { return new CToxOptionsMain((CToxProto*)param, IDD_OPTIONS_MAIN); } }; ///////////////////////////////////////////////////////////////////////////////// @@ -94,9 +92,10 @@ private: CCtrlNodeList m_nodes; CCtrlButton m_addNode; -protected: +public: CToxOptionsNodeList(CToxProto *proto); +protected: void OnInitDialog(); void OnApply(); @@ -104,9 +103,6 @@ protected: void OnNodeListDoubleClick(CCtrlBase*); void OnNodeListClick(CCtrlListView::TEventInfo *evt); void OnNodeListKeyDown(CCtrlListView::TEventInfo *evt); - -public: - static CDlgBase *CreateOptionsPage(void *param) { return new CToxOptionsNodeList((CToxProto*)param); } }; #endif //_TOX_OPTIONS_H_ \ No newline at end of file diff --git a/protocols/Tox/src/tox_profile.cpp b/protocols/Tox/src/tox_profile.cpp index 8ca4bf84a4..2affb68422 100644 --- a/protocols/Tox/src/tox_profile.cpp +++ b/protocols/Tox/src/tox_profile.cpp @@ -142,7 +142,7 @@ INT_PTR CToxProto::OnCopyToxID(WPARAM, LPARAM) } CToxPasswordEditor::CToxPasswordEditor(CToxProto *proto) : - CToxDlgBase(proto, IDD_PASSWORD, NULL, false), ok(this, IDOK), + CToxDlgBase(proto, IDD_PASSWORD, false), ok(this, IDOK), password(this, IDC_PASSWORD), savePermanently(this, IDC_SAVEPERMANENTLY) { ok.OnClick = Callback(this, &CToxPasswordEditor::OnOk); diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index a329252fda..82bfe006f3 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -131,9 +131,6 @@ private: INT_PTR __cdecl CToxProto::SetMyNickname(WPARAM wParam, LPARAM lParam); // options - CToxDlgBase::CreateParam ToxMainOptions; - CToxDlgBase::CreateParam ToxNodeListOptions; - int __cdecl OnOptionsInit(WPARAM wParam, LPARAM lParam); // events diff --git a/protocols/Tox/src/tox_search.cpp b/protocols/Tox/src/tox_search.cpp index f5d5b001b3..62671f7ac7 100644 --- a/protocols/Tox/src/tox_search.cpp +++ b/protocols/Tox/src/tox_search.cpp @@ -30,7 +30,7 @@ ToxHexAddress ResolveToxAddressFromDnsRecordV3(void *dns, uint32_t requestId, co { std::string id = match[1]; uint8_t data[TOX_ADDRESS_SIZE]; - if (tox_decrypt_dns3_TXT(dns, data, (uint8_t*)id.c_str(), id.length(), requestId) != TOX_ERROR) + if (tox_decrypt_dns3_TXT(dns, data, (uint8_t*)id.c_str(), (uint32_t)id.length(), requestId) != TOX_ERROR) { return ToxHexAddress(data, TOX_ADDRESS_SIZE); } @@ -69,7 +69,7 @@ void CToxProto::SearchByNameAsync(void *arg) uint32_t requestId = 0; uint8_t dnsString[MAX_PATH]; - int length = tox_generate_dns3_string(dns, dnsString, sizeof(dnsString), &requestId, (uint8_t*)name, mir_strlen(name)); + size_t length = tox_generate_dns3_string(dns, dnsString, sizeof(dnsString), &requestId, (uint8_t*)name, (uint8_t)mir_strlen(name)); if (length != TOX_ERROR) { dnsString[length] = 0; diff --git a/src/core/commonheaders.h b/src/core/commonheaders.h index d07cae5cd4..d9841639e4 100644 --- a/src/core/commonheaders.h +++ b/src/core/commonheaders.h @@ -95,6 +95,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #include +#include #include "miranda.h" #include "stdplug.h" diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index 8ddcd7f9ef..3809861dc2 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -641,9 +641,9 @@ mir_wstrcmpi @280 ??0CDbLink@@QAE@PBD0EK@Z @639 NONAME ??0CDbLink@@QAE@PBD0EPA_W@Z @640 NONAME ??0CDlgBase@@QAE@ABV0@@Z @641 NONAME -??0CDlgBase@@QAE@PAUHINSTANCE__@@HPAUHWND__@@@Z @642 NONAME +??0CDlgBase@@QAE@PAUHINSTANCE__@@H@Z @642 NONAME ??0CProtoIntDlgBase@@QAE@ABV0@@Z @643 NONAME -??0CProtoIntDlgBase@@QAE@PAUPROTO_INTERFACE@@HPAUHWND__@@_N@Z @644 NONAME +??0CProtoIntDlgBase@@QAE@PAUPROTO_INTERFACE@@H_N@Z @644 NONAME ??1CCtrlBase@@UAE@XZ @645 NONAME ??1CCtrlButton@@UAE@XZ @646 NONAME ??1CCtrlCheck@@UAE@XZ @647 NONAME @@ -739,7 +739,7 @@ mir_wstrcmpi @280 ?DlgProc@CDlgBase@@MAEHIIJ@Z @737 NONAME ?DlgProc@CProtoIntDlgBase@@MAEHIIJ@Z @738 NONAME ?DoModal@CDlgBase@@QAEHXZ @739 NONAME -?DynamicDlgProc@CDlgBase@@SGHPAUHWND__@@IIJ@Z @740 NONAME +?SetParent@CDlgBase@@QAEXPAUHWND__@@@Z @740 NONAME ?EditLabel@CCtrlClc@@QAEXPAX@Z @741 NONAME ?EditLabel@CCtrlListView@@QAEPAUHWND__@@H@Z @742 NONAME ?EditLabel@CCtrlTreeView@@QAEPAUHWND__@@PAU_TREEITEM@@@Z @743 NONAME diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index e934009cf4..0308488cca 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -641,9 +641,9 @@ mir_wstrcmpi @280 ??0CDbLink@@QEAA@PEBD0EK@Z @639 NONAME ??0CDbLink@@QEAA@PEBD0EPEA_W@Z @640 NONAME ??0CDlgBase@@QEAA@AEBV0@@Z @641 NONAME -??0CDlgBase@@QEAA@PEAUHINSTANCE__@@HPEAUHWND__@@@Z @642 NONAME +??0CDlgBase@@QEAA@PEAUHINSTANCE__@@H@Z @642 NONAME ??0CProtoIntDlgBase@@QEAA@AEBV0@@Z @643 NONAME -??0CProtoIntDlgBase@@QEAA@PEAUPROTO_INTERFACE@@HPEAUHWND__@@_N@Z @644 NONAME +??0CProtoIntDlgBase@@QEAA@PEAUPROTO_INTERFACE@@H_N@Z @644 NONAME ??1CCtrlBase@@UEAA@XZ @645 NONAME ??1CCtrlButton@@UEAA@XZ @646 NONAME ??1CCtrlCheck@@UEAA@XZ @647 NONAME @@ -739,7 +739,7 @@ mir_wstrcmpi @280 ?DlgProc@CDlgBase@@MEAA_JI_K_J@Z @737 NONAME ?DlgProc@CProtoIntDlgBase@@MEAA_JI_K_J@Z @738 NONAME ?DoModal@CDlgBase@@QEAAHXZ @739 NONAME -?DynamicDlgProc@CDlgBase@@SA_JPEAUHWND__@@I_K_J@Z @740 NONAME +?SetParent@CDlgBase@@QEAAXPEAUHWND__@@@Z @740 NONAME ?EditLabel@CCtrlClc@@QEAAXPEAX@Z @741 NONAME ?EditLabel@CCtrlListView@@QEAAPEAUHWND__@@H@Z @742 NONAME ?EditLabel@CCtrlTreeView@@QEAAPEAUHWND__@@PEAU_TREEITEM@@@Z @743 NONAME @@ -1074,3 +1074,4 @@ ProtoWindowAdd @1071 NONAME ProtoWindowRemove @1072 NONAME Proto_IsProtocolLoaded @1073 NONAME Proto_RegisterModule @1074 NONAME + diff --git a/src/mir_core/src/ui_utils.cpp b/src/mir_core/src/ui_utils.cpp index 22f46ea743..4f574896f8 100644 --- a/src/mir_core/src/ui_utils.cpp +++ b/src/mir_core/src/ui_utils.cpp @@ -29,12 +29,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #pragma comment(lib, "uxtheme") -CDlgBase::CDlgBase(HINSTANCE hInst, int idDialog, HWND hwndParent) : +CDlgBase::CDlgBase(HINSTANCE hInst, int idDialog) : m_controls(1, CCtrlBase::cmp) { m_hInst = hInst; m_idDialog = idDialog; - m_hwndParent = hwndParent; + m_hwndParent = NULL; m_hwnd = NULL; m_first = NULL; m_isModal = false; @@ -1943,8 +1943,8 @@ void CDbLink::SaveText(TCHAR *value) ///////////////////////////////////////////////////////////////////////////////////////// // Base protocol dialog -CProtoIntDlgBase::CProtoIntDlgBase(PROTO_INTERFACE *proto, int idDialog, HWND parent, bool show_label) : - CDlgBase(::ProtoGetInstance(proto->m_szModuleName), idDialog, parent), +CProtoIntDlgBase::CProtoIntDlgBase(PROTO_INTERFACE *proto, int idDialog, bool show_label) : + CDlgBase(::ProtoGetInstance(proto->m_szModuleName), idDialog), m_proto_interface(proto), m_show_label(show_label), m_hwndStatus(NULL) diff --git a/src/modules/options/options.cpp b/src/modules/options/options.cpp index f9ae5965f7..48d33deb80 100644 --- a/src/modules/options/options.cpp +++ b/src/modules/options/options.cpp @@ -80,6 +80,7 @@ struct OptionsPageData int hLangpack; BOOL insideTab; LPARAM dwInitParam; + CDlgBase *pDialog; int offsetX; int offsetY; @@ -187,18 +188,6 @@ static void ThemeDialogBackground(HWND hwnd, BOOL tabbed) EnableThemeDialogTexture(hwnd, (tabbed ? ETDT_ENABLE : ETDT_DISABLE) | ETDT_USETABTEXTURE); } -static int lstrcmpnull(TCHAR *str1, TCHAR *str2) -{ - if (str1 == NULL && str2 == NULL) - return 0; - if (str1 != NULL && str2 == NULL) - return 1; - if (str1 == NULL && str2 != NULL) - return -1; - - return mir_tstrcmp(str1, str2); -} - static TCHAR* GetPluginName(HINSTANCE hInstance, TCHAR *buffer, int size) { TCHAR tszModuleName[MAX_PATH]; @@ -218,6 +207,18 @@ PageHash GetPluginPageHash(const OptionsPageData *page) return mir_hashstrT(page->ptszGroup) + mir_hashstrT(page->ptszTitle) + mir_hashstrT(page->ptszTab); } +static HWND CreateOptionWindow(const OptionsPageData *opd, HWND hWndParent) +{ + if (opd->pDialog != NULL) { + opd->pDialog->SetParent(hWndParent); + opd->pDialog->Create(); + return opd->pDialog->GetHwnd(); + } + + // create the options dialog page so we can parse it; + return CreateDialogIndirectParamA(opd->hInst, opd->pTemplate, hWndParent, opd->dlgProc, opd->dwInitParam); +} + static void FindFilterStrings(int enableKeywordFiltering, int current, HWND hWndParent, const OptionsPageData *page) { HWND hWnd = 0; @@ -225,7 +226,7 @@ static void FindFilterStrings(int enableKeywordFiltering, int current, HWND hWnd if (current) hWnd = page->hwnd; else { - hWnd = CreateDialogIndirectParamA(page->hInst, page->pTemplate, hWndParent, page->dlgProc, page->dwInitParam); //create the options dialog page so we can parse it + hWnd = CreateOptionWindow(page, hWndParent); ShowWindow(hWnd, SW_HIDE); // make sure it's hidden } } @@ -670,7 +671,7 @@ static BOOL IsInsideTab(HWND hdlg, OptionsDlgData *dat, int i) for (int j = 0; j < dat->arOpd.getCount() && pages < 2; j++) { OptionsPageData* opd2 = dat->arOpd[j]; if (!CheckPageShow(hdlg, dat, j)) continue; - if (mir_tstrcmp(opd2->ptszTitle, opd->ptszTitle) || lstrcmpnull(opd2->ptszGroup, opd->ptszGroup)) + if (mir_tstrcmp(opd2->ptszTitle, opd->ptszTitle) || mir_tstrcmp(opd2->ptszGroup, opd->ptszGroup)) continue; pages++; } @@ -680,38 +681,43 @@ static BOOL IsInsideTab(HWND hdlg, OptionsDlgData *dat, int i) static bool LoadOptionsPage(OPTIONSDIALOGPAGE *src, OptionsPageData *dst) { - HRSRC hrsrc = FindResourceA(src->hInstance, src->pszTemplate, MAKEINTRESOURCEA(5)); - if (hrsrc == NULL) - return false; - - HGLOBAL hglb = LoadResource(src->hInstance, hrsrc); - if (hglb == NULL) - return false; - - DWORD resSize = SizeofResource(src->hInstance, hrsrc); - dst->pTemplate = (DLGTEMPLATE*)mir_alloc(resSize); - memcpy(dst->pTemplate, LockResource(hglb), resSize); - DlgTemplateExBegin *dte = (struct DlgTemplateExBegin*)dst->pTemplate; - if (dte->signature == 0xFFFF) { - //this feels like an access violation, and is according to boundschecker - //...but it works - for now - //may well have to remove and sort out the original dialogs - dte->style &= ~(WS_VISIBLE | WS_CHILD | WS_POPUP | WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | DS_MODALFRAME | DS_CENTER); - dte->style |= WS_CHILD; - } - else { - dst->pTemplate->style &= ~(WS_VISIBLE | WS_CHILD | WS_POPUP | WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | DS_MODALFRAME | DS_CENTER); - dst->pTemplate->style |= WS_CHILD; + // old fashioned Windows dialog loading + if (src->hInstance != NULL && src->pszTemplate != NULL) { + HRSRC hrsrc = FindResourceA(src->hInstance, src->pszTemplate, MAKEINTRESOURCEA(5)); + if (hrsrc == NULL) + return false; + + HGLOBAL hglb = LoadResource(src->hInstance, hrsrc); + if (hglb == NULL) + return false; + + DWORD resSize = SizeofResource(src->hInstance, hrsrc); + dst->pTemplate = (DLGTEMPLATE*)mir_alloc(resSize); + memcpy(dst->pTemplate, LockResource(hglb), resSize); + DlgTemplateExBegin *dte = (struct DlgTemplateExBegin*)dst->pTemplate; + if (dte->signature == 0xFFFF) { + //this feels like an access violation, and is according to boundschecker + //...but it works - for now + //may well have to remove and sort out the original dialogs + dte->style &= ~(WS_VISIBLE | WS_CHILD | WS_POPUP | WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | DS_MODALFRAME | DS_CENTER); + dte->style |= WS_CHILD; + } + else { + dst->pTemplate->style &= ~(WS_VISIBLE | WS_CHILD | WS_POPUP | WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | DS_MODALFRAME | DS_CENTER); + dst->pTemplate->style |= WS_CHILD; + } + dst->hInst = src->hInstance; + dst->dlgProc = src->pfnDlgProc; + dst->dwInitParam = src->dwInitParam; } - dst->dlgProc = src->pfnDlgProc; - dst->hInst = src->hInstance; + else dst->pDialog = src->pDialog; + dst->hwnd = NULL; dst->changed = 0; dst->height = 0; dst->width = 0; dst->flags = src->flags; dst->hLangpack = src->hLangpack; - dst->dwInitParam = src->dwInitParam; if (src->pszTitle == NULL) dst->ptszTitle = NULL; else if (src->flags & ODPF_UNICODE) @@ -856,8 +862,8 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L } dat->arOpd.insert(opd); - if (!mir_tstrcmp(lastPage, odp->ptszTitle) && !lstrcmpnull(lastGroup, odp->ptszGroup)) - if ((ood->pszTab == NULL && dat->currentPage == -1) || !lstrcmpnull(lastTab, odp->ptszTab)) + if (!mir_tstrcmp(lastPage, odp->ptszTitle) && !mir_tstrcmp(lastGroup, odp->ptszGroup)) + if ((ood->pszTab == NULL && dat->currentPage == -1) || !mir_tstrcmp(lastTab, odp->ptszTab)) dat->currentPage = (int)i; } @@ -970,7 +976,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L break; } if (opd->hwnd == NULL) { - opd->hwnd = CreateDialogIndirectParamA(opd->hInst, opd->pTemplate, hdlg, opd->dlgProc, opd->dwInitParam); + opd->hwnd = CreateOptionWindow(opd, hdlg); if (opd->flags & ODPF_BOLDGROUPS) EnumChildWindows(opd->hwnd, BoldGroupTitlesEnumChildren, (LPARAM)dat->hBoldFont); @@ -1012,7 +1018,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L continue; OptionsPageData *p = dat->arOpd[i]; - if (mir_tstrcmp(opd->ptszTitle, p->ptszTitle) || lstrcmpnull(opd->ptszGroup, p->ptszGroup)) + if (mir_tstrcmp(opd->ptszTitle, p->ptszTitle) || mir_tstrcmp(opd->ptszGroup, p->ptszGroup)) continue; tie.pszText = TranslateTH(p->hLangpack, p->ptszTab); -- cgit v1.2.3