diff options
author | George Hazan <george.hazan@gmail.com> | 2015-04-22 22:00:24 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-04-22 22:00:24 +0000 |
commit | baea5e8a4a56cb1d9cabd8f35554fd1c4eb24345 (patch) | |
tree | 3a2115658f4b563b8d017ac925ffd9c8d721acf5 /src | |
parent | d42da082183eb03b61075d4867f7c53bfedc506e (diff) |
- UI Utils not to use GWLP_USERDATA;
- minor improvements
git-svn-id: http://svn.miranda-ng.org/main/trunk@13044 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r-- | src/mir_core/src/mir_core.def | 1 | ||||
-rw-r--r-- | src/mir_core/src/mir_core64.def | 1 | ||||
-rw-r--r-- | src/mir_core/src/ui_utils.cpp | 87 |
3 files changed, 55 insertions, 34 deletions
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index 8196e031dc..6935548cb0 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -696,7 +696,6 @@ mir_wstrcmpi @280 ??_7CDlgBase@@6B@ @694 NONAME
??_7CProtoIntDlgBase@@6B@ @695 NONAME
?ActivatePage@CCtrlPages@@QAEXH@Z @696 NONAME
-?ActiveMessage@CDlgBase@@QBEPBUtagMSG@@XZ @697 NONAME
?AddColumn@CCtrlListView@@QAEXHPA_WH@Z @698 NONAME
?AddContact@CCtrlClc@@QAEXI@Z @699 NONAME
?AddControl@CDlgBase@@IAEXPAVCCtrlBase@@@Z @700 NONAME
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index 6c7513dbbe..1e5e35b29c 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -696,7 +696,6 @@ mir_wstrcmpi @280 ??_7CDlgBase@@6B@ @694 NONAME
??_7CProtoIntDlgBase@@6B@ @695 NONAME
?ActivatePage@CCtrlPages@@QEAAXH@Z @696 NONAME
-?ActiveMessage@CDlgBase@@QEBAPEBUtagMSG@@XZ @697 NONAME
?AddColumn@CCtrlListView@@QEAAXHPEA_WH@Z @698 NONAME
?AddContact@CCtrlClc@@QEAAXI@Z @699 NONAME
?AddControl@CDlgBase@@IEAAXPEAVCCtrlBase@@@Z @700 NONAME
diff --git a/src/mir_core/src/ui_utils.cpp b/src/mir_core/src/ui_utils.cpp index 3411ada948..6912a5158c 100644 --- a/src/mir_core/src/ui_utils.cpp +++ b/src/mir_core/src/ui_utils.cpp @@ -27,6 +27,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <m_icolib.h>
#include <m_skin.h>
+static mir_cs csDialogs, csCtrl;
+
+static int CompareDialogs(const CDlgBase *p1, const CDlgBase *p2)
+{ return (INT_PTR)p1->GetHwnd() - (INT_PTR)p2->GetHwnd();
+}
+static LIST<CDlgBase> arDialogs(10, CompareDialogs);
+
+static int CompareDialogs(const CCtrlBase *p1, const CCtrlBase *p2)
+{ return (INT_PTR)p1->GetHwnd() - (INT_PTR)p2->GetHwnd();
+}
+static LIST<CCtrlBase> arControls(10, PtrKeySortT);
+
#pragma comment(lib, "uxtheme")
CDlgBase::CDlgBase(HINSTANCE hInst, int idDialog) :
@@ -180,8 +192,12 @@ INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) case WM_DESTROY:
OnDestroy();
NotifyControls(&CCtrlBase::OnDestroy);
-
- SetWindowLongPtr(m_hwnd, GWLP_USERDATA, 0);
+ {
+ mir_cslock lck(csDialogs);
+ int idx = arDialogs.getIndex(this);
+ if (idx != -1)
+ arDialogs.remove(idx);
+ }
m_hwnd = NULL;
if (m_isModal)
m_isModal = false;
@@ -198,19 +214,21 @@ INT_PTR CALLBACK CDlgBase::GlobalDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPA {
CDlgBase *wnd = NULL;
if (msg == WM_INITDIALOG) {
- SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam);
- wnd = (CDlgBase *)lParam;
+ wnd = (CDlgBase*)lParam;
wnd->m_hwnd = hwnd;
+
+ mir_cslock lck(csDialogs);
+ arDialogs.insert(wnd);
+ }
+ else {
+ PVOID bullshit[2]; // vfptr + hwnd
+ bullshit[1] = hwnd;
+ wnd = arDialogs.find((CDlgBase*)&bullshit);
}
- else wnd = (CDlgBase *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- if (!wnd)
+ if (wnd == NULL)
return FALSE;
- wnd->m_msg.hwnd = hwnd;
- wnd->m_msg.message = msg;
- wnd->m_msg.wParam = wParam;
- wnd->m_msg.lParam = lParam;
return wnd->DlgProc(msg, wParam, lParam);
}
@@ -1512,16 +1530,6 @@ HTREEITEM CCtrlTreeView::InsertItem(TVINSERTSTRUCT *tvis) { return TreeView_InsertItem(m_hwnd, tvis);
}
-/*
-HTREEITEM CCtrlTreeView::MapAccIDToHTREEITEM(UINT id)
-{ return TreeView_MapAccIDToHTREEITEM(m_hwnd, id);
-}
-
-UINT CCtrlTreeView::MapHTREEITEMtoAccID(HTREEITEM hItem)
-{ return TreeView_MapHTREEITEMtoAccID(m_hwnd, hItem);
-}
-
-*/
void CCtrlTreeView::Select(HTREEITEM hItem, DWORD flag)
{ TreeView_Select(m_hwnd, hItem, flag);
}
@@ -1761,8 +1769,7 @@ void CCtrlPages::OnDestroy() CCtrlBase::CCtrlBase(CDlgBase *wnd, int idCtrl) :
m_parentWnd(wnd),
m_idCtrl(idCtrl),
- m_hwnd(NULL),
- m_wndproc(NULL)
+ m_hwnd(NULL)
{
if (wnd) {
m_next = wnd->m_first;
@@ -1778,7 +1785,6 @@ void CCtrlBase::OnInit() void CCtrlBase::OnDestroy()
{
- Unsubclass();
m_hwnd = NULL;
}
@@ -1854,23 +1860,40 @@ int CCtrlBase::GetInt() LRESULT CCtrlBase::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
- if (msg == WM_DESTROY) Unsubclass();
- return CallWindowProc(m_wndproc, m_hwnd, msg, wParam, lParam);
+ return FALSE;
+}
+
+LRESULT CALLBACK CCtrlBase::GlobalSubclassWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ PVOID bullshit[2]; // vfptr + hwnd
+ bullshit[1] = hwnd;
+ CCtrlBase *pCtrl = arControls.find((CCtrlBase*)&bullshit);
+ if (pCtrl) {
+ LRESULT res = pCtrl->CustomWndProc(msg, wParam, lParam);
+ if (msg == WM_DESTROY) {
+ pCtrl->Unsubclass();
+ arControls.remove(pCtrl);
+ }
+
+ if (res != 0)
+ return res;
+ }
+
+ return mir_callNextSubclass(hwnd, GlobalSubclassWndProc, msg, wParam, lParam);
}
void CCtrlBase::Subclass()
{
- SetWindowLongPtr(m_hwnd, GWLP_USERDATA, (LONG_PTR)this);
- m_wndproc = (WNDPROC)SetWindowLongPtr(m_hwnd, GWLP_WNDPROC, (LONG_PTR)GlobalSubclassWndProc);
+ mir_subclassWindow(m_hwnd, GlobalSubclassWndProc);
+
+ mir_cslock lck(csCtrl);
+ arControls.insert(this);
}
void CCtrlBase::Unsubclass()
{
- if (m_wndproc) {
- SetWindowLongPtr(m_hwnd, GWLP_WNDPROC, (LONG_PTR)m_wndproc);
- SetWindowLongPtr(m_hwnd, GWLP_USERDATA, 0);
- m_wndproc = 0;
-} }
+ mir_unsubclassWindow(m_hwnd, GlobalSubclassWndProc);
+}
/////////////////////////////////////////////////////////////////////////////////////////
// CDbLink class
|