summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-05-12 21:28:06 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-05-12 21:28:06 +0000
commita4f715971c8c0f5be8f8fcc8678c7dd57cab0f8e (patch)
tree4bca82393f90685c3c9b3a0420745cf24bd84e28 /src
parentb3742e87f4003a80c13ece74264397b6c137096b (diff)
- CCtrlData::OnChange moved to CCtrlBase, because almost all controls can send change notifications;
- checkbox manager for CCtrlTreeView moved into the core, to remove Windows-dependent code from plugins; - MTREE_CHECKBOX & MTREE_DND flags introduced to turn on predefined behaviors of a tree control - typo fixed git-svn-id: http://svn.miranda-ng.org/main/trunk@13564 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r--src/mir_core/src/mir_core.def10
-rw-r--r--src/mir_core/src/mir_core64.def10
-rw-r--r--src/mir_core/src/ui_utils.cpp268
-rw-r--r--src/modules/clist/contacts.cpp108
-rw-r--r--src/modules/clist/genmenuopt.cpp89
-rw-r--r--src/modules/clist/protocolorder.cpp39
6 files changed, 310 insertions, 214 deletions
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def
index 9234c6236a..4e55fce8cf 100644
--- a/src/mir_core/src/mir_core.def
+++ b/src/mir_core/src/mir_core.def
@@ -870,7 +870,7 @@ mir_wstrcmpi @280
?GetTextBkColor@CCtrlListView@@QAEKXZ @869 NONAME
?GetTextColor@CCtrlListView@@QAEKXZ @870 NONAME
?GetTextColor@CCtrlTreeView@@QAEKXZ @871 NONAME
-?GetTextColot@CCtrlClc@@QAEKH@Z @872 NONAME
+?GetTextColor@CCtrlClc@@QAEKH@Z @872 NONAME
?GetTileInfo@CCtrlListView@@QAEXPAUtagLVTILEINFO@@@Z @873 NONAME
?GetTileViewInfo@CCtrlListView@@QAEXPAUtagLVTILEVIEWINFO@@@Z @874 NONAME
?GetToolTips@CCtrlListView@@QAEPAUHWND__@@XZ @875 NONAME
@@ -897,7 +897,7 @@ mir_wstrcmpi @280
?InsertMarkHitTest@CCtrlListView@@QAEHPAUtagPOINT@@PAULVINSERTMARK@@@Z @896 NONAME
?InsertString@CCtrlCombo@@QAEHPA_WHJ@Z @897 NONAME
?InsertString@CCtrlListBox@@QAEHPA_WHJ@Z @898 NONAME
-?IsChanged@CCtrlData@@QBE_NXZ @899 NONAME
+?IsChanged@CCtrlBase@@QBE_NXZ @899 NONAME
?IsGroupViewEnabled@CCtrlListView@@QAEHXZ @900 NONAME
?IsInitialized@CDlgBase@@QBE_NXZ @901 NONAME
?LoadInt@CCtrlData@@IAEKXZ @902 NONAME
@@ -908,7 +908,7 @@ mir_wstrcmpi @280
?MakePush@CCtrlMButton@@QAEXXZ @907 NONAME
?MapIDToIndex@CCtrlListView@@QAEII@Z @908 NONAME
?MapIndexToID@CCtrlListView@@QAEII@Z @909 NONAME
-?NotifyChange@CCtrlData@@IAEXXZ @910 NONAME
+?NotifyChange@CCtrlBase@@QAEXXZ @910 NONAME
?NotifyControls@CDlgBase@@AAEXP8CCtrlBase@@AEXXZ@Z @911 NONAME
?OnApply@CCtrlBase@@UAEXXZ @912 NONAME
?OnApply@CCtrlCheck@@UAEXXZ @913 NONAME
@@ -930,10 +930,8 @@ mir_wstrcmpi @280
?OnDestroy@CDlgBase@@MAEXXZ @929 NONAME
?OnDrawItem@CCtrlBase@@UAEHPAUtagDRAWITEMSTRUCT@@@Z @930 NONAME
?OnInit@CCtrlBase@@UAEXXZ @931 NONAME
-?OnInit@CCtrlCheck@@UAEXXZ @932 NONAME
?OnInit@CCtrlCombo@@UAEXXZ @933 NONAME
?OnInit@CCtrlData@@UAEXXZ @934 NONAME
-?OnInit@CCtrlEdit@@UAEXXZ @935 NONAME
?OnInit@CCtrlMButton@@UAEXXZ @936 NONAME
?OnInit@CCtrlPages@@MAEXXZ @937 NONAME
?OnInitDialog@CDlgBase@@MAEXXZ @938 NONAME
@@ -1077,3 +1075,5 @@ Proto_RegisterModule @1074 NONAME
?Find@CDlgBase@@SAPAV1@PAUHWND__@@@Z @1076 NONAME
?SetCaption@CDlgBase@@QAEXPB_W@Z @1077 NONAME
?NotifyChange@CDlgBase@@QAEXXZ @1078 NONAME
+?InvertCheck@CCtrlTreeView@@QAEXPAU_TREEITEM@@@Z @1079 NONAME
+?SetFlags@CCtrlTreeView@@QAEXI@Z @1080 NONAME
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def
index cea83c2f8a..6da78214f5 100644
--- a/src/mir_core/src/mir_core64.def
+++ b/src/mir_core/src/mir_core64.def
@@ -870,7 +870,7 @@ mir_wstrcmpi @280
?GetTextBkColor@CCtrlListView@@QEAAKXZ @869 NONAME
?GetTextColor@CCtrlListView@@QEAAKXZ @870 NONAME
?GetTextColor@CCtrlTreeView@@QEAAKXZ @871 NONAME
-?GetTextColot@CCtrlClc@@QEAAKH@Z @872 NONAME
+?GetTextColor@CCtrlClc@@QEAAKH@Z @872 NONAME
?GetTileInfo@CCtrlListView@@QEAAXPEAUtagLVTILEINFO@@@Z @873 NONAME
?GetTileViewInfo@CCtrlListView@@QEAAXPEAUtagLVTILEVIEWINFO@@@Z @874 NONAME
?GetToolTips@CCtrlListView@@QEAAPEAUHWND__@@XZ @875 NONAME
@@ -897,7 +897,7 @@ mir_wstrcmpi @280
?InsertMarkHitTest@CCtrlListView@@QEAAHPEAUtagPOINT@@PEAULVINSERTMARK@@@Z @896 NONAME
?InsertString@CCtrlCombo@@QEAAHPEA_WH_J@Z @897 NONAME
?InsertString@CCtrlListBox@@QEAAHPEA_WH_J@Z @898 NONAME
-?IsChanged@CCtrlData@@QEBA_NXZ @899 NONAME
+?IsChanged@CCtrlBase@@QEBA_NXZ @899 NONAME
?IsGroupViewEnabled@CCtrlListView@@QEAAHXZ @900 NONAME
?IsInitialized@CDlgBase@@QEBA_NXZ @901 NONAME
?LoadInt@CCtrlData@@IEAAKXZ @902 NONAME
@@ -908,7 +908,7 @@ mir_wstrcmpi @280
?MakePush@CCtrlMButton@@QEAAXXZ @907 NONAME
?MapIDToIndex@CCtrlListView@@QEAAII@Z @908 NONAME
?MapIndexToID@CCtrlListView@@QEAAII@Z @909 NONAME
-?NotifyChange@CCtrlData@@IEAAXXZ @910 NONAME
+?NotifyChange@CCtrlBase@@QEAAXXZ @910 NONAME
?NotifyControls@CDlgBase@@AEAAXP8CCtrlBase@@EAAXXZ@Z @911 NONAME
?OnApply@CCtrlBase@@UEAAXXZ @912 NONAME
?OnApply@CCtrlCheck@@UEAAXXZ @913 NONAME
@@ -930,10 +930,8 @@ mir_wstrcmpi @280
?OnDestroy@CDlgBase@@MEAAXXZ @929 NONAME
?OnDrawItem@CCtrlBase@@UEAAHPEAUtagDRAWITEMSTRUCT@@@Z @930 NONAME
?OnInit@CCtrlBase@@UEAAXXZ @931 NONAME
-?OnInit@CCtrlCheck@@UEAAXXZ @932 NONAME
?OnInit@CCtrlCombo@@UEAAXXZ @933 NONAME
?OnInit@CCtrlData@@UEAAXXZ @934 NONAME
-?OnInit@CCtrlEdit@@UEAAXXZ @935 NONAME
?OnInit@CCtrlMButton@@UEAAXXZ @936 NONAME
?OnInit@CCtrlPages@@MEAAXXZ @937 NONAME
?OnInitDialog@CDlgBase@@MEAAXXZ @938 NONAME
@@ -1077,3 +1075,5 @@ Proto_RegisterModule @1074 NONAME
?Find@CDlgBase@@SAPEAV1@PEAUHWND__@@@Z @1076 NONAME
?SetCaption@CDlgBase@@QEAAXPEB_W@Z @1077 NONAME
?NotifyChange@CDlgBase@@QEAAXXZ @1078 NONAME
+?InvertCheck@CCtrlTreeView@@QEAAXPEAU_TREEITEM@@@Z @1079 NONAME
+?SetFlags@CCtrlTreeView@@QEAAXI@Z @1080 NONAME
diff --git a/src/mir_core/src/ui_utils.cpp b/src/mir_core/src/ui_utils.cpp
index 8df0253782..700dd30f67 100644
--- a/src/mir_core/src/ui_utils.cpp
+++ b/src/mir_core/src/ui_utils.cpp
@@ -280,6 +280,51 @@ CCtrlCombo::CCtrlCombo(CDlgBase* dlg, int ctrlId) :
{
}
+BOOL CCtrlCombo::OnCommand(HWND, WORD, WORD idCode)
+{
+ switch (idCode) {
+ case CBN_CLOSEUP: OnCloseup(this); break;
+ case CBN_DROPDOWN: OnDropdown(this); break;
+
+ case CBN_EDITCHANGE:
+ case CBN_EDITUPDATE:
+ case CBN_SELCHANGE:
+ case CBN_SELENDOK:
+ NotifyChange();
+ break;
+ }
+ return TRUE;
+}
+
+void CCtrlCombo::OnInit()
+{
+ CSuper::OnInit();
+ OnReset();
+}
+
+void CCtrlCombo::OnApply()
+{
+ CSuper::OnApply();
+
+ if (GetDataType() == DBVT_TCHAR) {
+ int len = GetWindowTextLength(m_hwnd) + 1;
+ TCHAR *buf = (TCHAR *)_alloca(sizeof(TCHAR) * len);
+ GetWindowText(m_hwnd, buf, len);
+ SaveText(buf);
+ }
+ else if (GetDataType() != DBVT_DELETED) {
+ SaveInt(GetInt());
+ }
+}
+
+void CCtrlCombo::OnReset()
+{
+ if (GetDataType() == DBVT_TCHAR)
+ SetText(LoadText());
+ else if (GetDataType() != DBVT_DELETED)
+ SetInt(LoadInt());
+}
+
int CCtrlCombo::AddString(const TCHAR *text, LPARAM data)
{
int iItem = SendMessage(m_hwnd, CB_ADDSTRING, 0, (LPARAM)text);
@@ -484,14 +529,30 @@ CCtrlCheck::CCtrlCheck(CDlgBase* dlg, int ctrlId) :
{
}
-int CCtrlCheck::GetState()
+BOOL CCtrlCheck::OnCommand(HWND, WORD, WORD)
{
- return SendMessage(m_hwnd, BM_GETCHECK, 0, 0);
+ NotifyChange();
+ return TRUE;
}
-void CCtrlCheck::SetState(int state)
+void CCtrlCheck::OnApply()
{
- SendMessage(m_hwnd, BM_SETCHECK, state, 0);
+ CSuper::OnApply();
+
+ SaveInt(GetState());
+}
+
+void CCtrlCheck::OnReset()
+{
+ SetState(LoadInt());
+}
+
+int CCtrlCheck::GetState()
+{ return SendMessage(m_hwnd, BM_GETCHECK, 0, 0);
+}
+
+void CCtrlCheck::SetState(int state)
+{ SendMessage(m_hwnd, BM_SETCHECK, state, 0);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -502,31 +563,55 @@ CCtrlEdit::CCtrlEdit(CDlgBase* dlg, int ctrlId) :
{
}
+BOOL CCtrlEdit::OnCommand(HWND, WORD, WORD idCode)
+{
+ if (idCode == EN_CHANGE)
+ NotifyChange();
+ return TRUE;
+}
+
+void CCtrlEdit::OnApply()
+{
+ CSuper::OnApply();
+
+ if (GetDataType() == DBVT_TCHAR) {
+ int len = GetWindowTextLength(m_hwnd) + 1;
+ TCHAR *buf = (TCHAR *)_alloca(sizeof(TCHAR) * len);
+ GetWindowText(m_hwnd, buf, len);
+ SaveText(buf);
+ }
+ else if (GetDataType() != DBVT_DELETED) {
+ SaveInt(GetInt());
+ }
+}
+
+void CCtrlEdit::OnReset()
+{
+ if (GetDataType() == DBVT_TCHAR)
+ SetText(LoadText());
+ else if (GetDataType() != DBVT_DELETED)
+ SetInt(LoadInt());
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
// CCtrlData class
CCtrlData::CCtrlData(CDlgBase *wnd, int idCtrl) :
CCtrlBase(wnd, idCtrl),
- m_dbLink(NULL),
- m_changed(false)
+ m_dbLink(NULL)
{
}
-void CCtrlData::OnInit()
+CCtrlData::~CCtrlData()
{
- CCtrlBase::OnInit();
+ if (m_dbLink)
+ delete m_dbLink;
}
-void CCtrlData::NotifyChange()
+void CCtrlData::OnInit()
{
- if (!m_parentWnd || m_parentWnd->IsInitialized()) m_changed = true;
- if (m_parentWnd) {
- m_parentWnd->OnChange(this);
- if (m_parentWnd->IsInitialized())
- ::SendMessage(::GetParent(m_parentWnd->GetHwnd()), PSM_CHANGED, 0, 0);
- }
-
- OnChange(this);
+ CCtrlBase::OnInit();
+ OnReset();
}
void CCtrlData::CreateDbLink(const char* szModuleName, const char* szSetting, BYTE type, DWORD iValue)
@@ -814,7 +899,7 @@ HANDLE CCtrlClc::GetNextItem(HANDLE hItem, DWORD flags)
{ return (HANDLE)SendMessage(m_hwnd, CLM_GETNEXTITEM, (WPARAM)flags, (LPARAM)hItem);
}
-COLORREF CCtrlClc::GetTextColot(int iFontId)
+COLORREF CCtrlClc::GetTextColor(int iFontId)
{ return (COLORREF)SendMessage(m_hwnd, CLM_GETTEXTCOLOR, (WPARAM)iFontId, 0);
}
@@ -1272,9 +1357,6 @@ BOOL CCtrlListView::SortItemsEx(PFNLVCOMPARE pfnCompare, LPARAM lParamSort)
INT CCtrlListView::SubItemHitTest(LPLVHITTESTINFO pInfo)
{ return ListView_SubItemHitTest(m_hwnd, pInfo);
}
-//INT CCtrlListView::SubItemHitTestEx(LPLVHITTESTINFO plvhti)
-//{ return ListView_SubItemHitTestEx(m_hwnd, plvhti);
-//}
BOOL CCtrlListView::Update(int iItem)
{ return ListView_Update(m_hwnd, iItem);
}
@@ -1283,8 +1365,21 @@ BOOL CCtrlListView::Update(int iItem)
// CCtrlTreeView
CCtrlTreeView::CCtrlTreeView(CDlgBase* dlg, int ctrlId):
- CCtrlBase(dlg, ctrlId)
+ CCtrlBase(dlg, ctrlId),
+ m_dwFlags(0)
+{
+}
+
+void CCtrlTreeView::SetFlags(uint32_t dwFlags)
{
+ if (dwFlags & MTREE_CHECKBOX)
+ m_bCheckBox = true;
+
+ if (dwFlags & MTREE_DND) {
+ m_bDndEnabled = true;
+ m_bDragging = false;
+ m_hDragItem = NULL;
+ }
}
BOOL CCtrlTreeView::OnNotify(int, NMHDR *pnmh)
@@ -1292,25 +1387,55 @@ BOOL CCtrlTreeView::OnNotify(int, NMHDR *pnmh)
TEventInfo evt = { this, pnmh };
switch (pnmh->code) {
- case TVN_BEGINDRAG: OnBeginDrag(&evt); return TRUE;
- case TVN_BEGINLABELEDIT: OnBeginLabelEdit(&evt); return TRUE;
- case TVN_BEGINRDRAG: OnBeginRDrag(&evt); return TRUE;
- case TVN_DELETEITEM: OnDeleteItem(&evt); return TRUE;
- case TVN_ENDLABELEDIT: OnEndLabelEdit(&evt); return TRUE;
- case TVN_GETDISPINFO: OnGetDispInfo(&evt); return TRUE;
- case TVN_GETINFOTIP: OnGetInfoTip(&evt); return TRUE;
- case TVN_ITEMEXPANDED: OnItemExpanded(&evt); return TRUE;
- case TVN_ITEMEXPANDING: OnItemExpanding(&evt); return TRUE;
- case TVN_KEYDOWN: OnKeyDown(&evt); return TRUE;
- case TVN_SELCHANGED: OnSelChanged(&evt); return TRUE;
- case TVN_SELCHANGING: OnSelChanging(&evt); return TRUE;
- case TVN_SETDISPINFO: OnSetDispInfo(&evt); return TRUE;
- case TVN_SINGLEEXPAND: OnSingleExpand(&evt); return TRUE;
+ case TVN_BEGINDRAG: OnBeginDrag(&evt); return TRUE;
+ case TVN_BEGINLABELEDIT: OnBeginLabelEdit(&evt); return TRUE;
+ case TVN_BEGINRDRAG: OnBeginRDrag(&evt); return TRUE;
+ case TVN_DELETEITEM: OnDeleteItem(&evt); return TRUE;
+ case TVN_ENDLABELEDIT: OnEndLabelEdit(&evt); return TRUE;
+ case TVN_GETDISPINFO: OnGetDispInfo(&evt); return TRUE;
+ case TVN_GETINFOTIP: OnGetInfoTip(&evt); return TRUE;
+ case TVN_ITEMEXPANDED: OnItemExpanded(&evt); return TRUE;
+ case TVN_ITEMEXPANDING: OnItemExpanding(&evt); return TRUE;
+ case TVN_SELCHANGED: OnSelChanged(&evt); return TRUE;
+ case TVN_SELCHANGING: OnSelChanging(&evt); return TRUE;
+ case TVN_SETDISPINFO: OnSetDispInfo(&evt); return TRUE;
+ case TVN_SINGLEEXPAND: OnSingleExpand(&evt); return TRUE;
+
+ case TVN_KEYDOWN:
+ if (m_bCheckBox && evt.nmtvkey->wVKey == VK_SPACE)
+ InvertCheck(GetSelection());
+
+ OnKeyDown(&evt);
+ return TRUE;
+ }
+
+ if (m_bCheckBox && pnmh->code == NM_CLICK) {
+ TVHITTESTINFO hti;
+ hti.pt.x = (short)LOWORD(GetMessagePos());
+ hti.pt.y = (short)HIWORD(GetMessagePos());
+ ScreenToClient(pnmh->hwndFrom, &hti.pt);
+ if (HitTest(&hti))
+ if (hti.flags & TVHT_ONITEMICON)
+ InvertCheck(hti.hItem);
}
return FALSE;
}
+void CCtrlTreeView::InvertCheck(HTREEITEM hItem)
+{
+ TVITEMEX tvi;
+ tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
+ tvi.hItem = hItem;
+ if (!GetItem(&tvi))
+ return;
+
+ tvi.iImage = tvi.iSelectedImage = !tvi.iImage;
+ SetItem(&tvi);
+
+ NotifyChange();
+}
+
void CCtrlTreeView::TranslateItem(HTREEITEM hItem)
{
TVITEMEX tvi;
@@ -1651,14 +1776,12 @@ void CCtrlPages::AddPage(TCHAR *ptszName, HICON hIcon, CCallback<void> onCreate,
info->m_param = param;
info->m_pDlg = NULL;
- TCITEM tci = {0};
- tci.mask = TCIF_PARAM|TCIF_TEXT;
+ TCITEM tci = { 0 };
+ tci.mask = TCIF_PARAM | TCIF_TEXT;
tci.lParam = (LPARAM)info;
tci.pszText = ptszName;
- if (hIcon)
- {
- if (!m_hIml)
- {
+ if (hIcon) {
+ if (!m_hIml) {
m_hIml = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 1);
TabCtrl_SetImageList(m_hwnd, m_hIml);
}
@@ -1675,7 +1798,7 @@ void CCtrlPages::AttachDialog(int iPage, CDlgBase *pDlg)
if ((iPage < 0) || (iPage >= TabCtrl_GetItemCount(m_hwnd)))
return;
- TCITEM tci = {0};
+ TCITEM tci = { 0 };
tci.mask = TCIF_PARAM;
TabCtrl_GetItem(m_hwnd, iPage, &tci);
@@ -1701,7 +1824,7 @@ void CCtrlPages::ShowPage(CDlgBase *pDlg)
GetClientRect(m_hwnd, &rc);
TabCtrl_AdjustRect(m_hwnd, FALSE, &rc);
MapWindowPoints(m_hwnd, ::GetParent(m_hwnd), (LPPOINT)&rc, 2);
- SetWindowPos(pDlg->GetHwnd(), HWND_TOP, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, SWP_SHOWWINDOW);
+ SetWindowPos(pDlg->GetHwnd(), HWND_TOP, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_SHOWWINDOW);
}
void CCtrlPages::ActivatePage(int iPage)
@@ -1715,7 +1838,7 @@ BOOL CCtrlPages::OnNotify(int /*idCtrl*/, NMHDR *pnmh)
switch (pnmh->code) {
case TCN_SELCHANGING:
{
- TCITEM tci = {0};
+ TCITEM tci = { 0 };
tci.mask = TCIF_PARAM;
TabCtrl_GetItem(m_hwnd, TabCtrl_GetCurSel(m_hwnd), &tci);
@@ -1730,7 +1853,7 @@ BOOL CCtrlPages::OnNotify(int /*idCtrl*/, NMHDR *pnmh)
case TCN_SELCHANGE:
{
- TCITEM tci = {0};
+ TCITEM tci = { 0 };
tci.mask = TCIF_PARAM;
TabCtrl_GetItem(m_hwnd, TabCtrl_GetCurSel(m_hwnd), &tci);
@@ -1754,8 +1877,8 @@ BOOL CCtrlPages::OnNotify(int /*idCtrl*/, NMHDR *pnmh)
void CCtrlPages::OnDestroy()
{
int count = TabCtrl_GetItemCount(m_hwnd);
- for (int i=0; i < count; i++) {
- TCITEM tci = {0};
+ for (int i = 0; i < count; i++) {
+ TCITEM tci = { 0 };
tci.mask = TCIF_PARAM;
TabCtrl_GetItem(m_hwnd, i, &tci);
@@ -1778,10 +1901,11 @@ void CCtrlPages::OnDestroy()
/////////////////////////////////////////////////////////////////////////////////////////
// CCtrlBase
-CCtrlBase::CCtrlBase(CDlgBase *wnd, int idCtrl) :
- m_parentWnd(wnd),
+CCtrlBase::CCtrlBase(CDlgBase *wnd, int idCtrl)
+ : m_parentWnd(wnd),
m_idCtrl(idCtrl),
- m_hwnd(NULL)
+ m_hwnd(NULL),
+ m_bChanged(false)
{
if (wnd) {
m_next = wnd->m_first;
@@ -1800,6 +1924,15 @@ void CCtrlBase::OnDestroy()
m_hwnd = NULL;
}
+void CCtrlBase::OnApply()
+{
+ m_bChanged = false;
+}
+
+void CCtrlBase::OnReset()
+{
+}
+
void CCtrlBase::Enable(int bIsEnable)
{
::EnableWindow(m_hwnd, bIsEnable);
@@ -1810,6 +1943,20 @@ BOOL CCtrlBase::Enabled() const
return (m_hwnd) ? IsWindowEnabled(m_hwnd) : FALSE;
}
+void CCtrlBase::NotifyChange()
+{
+ if (!m_parentWnd || m_parentWnd->IsInitialized())
+ m_bChanged = true;
+
+ if (m_parentWnd) {
+ m_parentWnd->OnChange(this);
+ if (m_parentWnd->IsInitialized())
+ ::SendMessage(::GetParent(m_parentWnd->GetHwnd()), PSM_CHANGED, 0, 0);
+ }
+
+ OnChange(this);
+}
+
LRESULT CCtrlBase::SendMsg(UINT Msg, WPARAM wParam, LPARAM lParam)
{
return ::SendMessage(m_hwnd, Msg, wParam, lParam);
@@ -1827,7 +1974,7 @@ void CCtrlBase::SetTextA(const char *text)
void CCtrlBase::SetInt(int value)
{
- TCHAR buf[32] = {0};
+ TCHAR buf[32] = { 0 };
mir_sntprintf(buf, SIZEOF(buf), _T("%d"), value);
SetWindowText(m_hwnd, buf);
}
@@ -1851,14 +1998,14 @@ char* CCtrlBase::GetTextA()
TCHAR* CCtrlBase::GetText(TCHAR *buf, int size)
{
GetWindowText(m_hwnd, buf, size);
- buf[size-1] = 0;
+ buf[size - 1] = 0;
return buf;
}
char* CCtrlBase::GetTextA(char *buf, int size)
{
GetWindowTextA(m_hwnd, buf, size);
- buf[size-1] = 0;
+ buf[size - 1] = 0;
return buf;
}
@@ -1897,7 +2044,7 @@ LRESULT CALLBACK CCtrlBase::GlobalSubclassWndProc(HWND hwnd, UINT msg, WPARAM wP
void CCtrlBase::Subclass()
{
mir_subclassWindow(m_hwnd, GlobalSubclassWndProc);
-
+
mir_cslock lck(csCtrl);
arControls.insert(this);
}
@@ -1978,12 +2125,13 @@ void CDbLink::SaveText(TCHAR *value)
/////////////////////////////////////////////////////////////////////////////////////////
// Base protocol dialog
-CProtoIntDlgBase::CProtoIntDlgBase(PROTO_INTERFACE *proto, int idDialog, bool show_label) :
- CDlgBase(::ProtoGetInstance(proto->m_szModuleName), idDialog),
+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)
-{}
+{
+}
void CProtoIntDlgBase::CreateLink(CCtrlData& ctrl, char *szSetting, BYTE type, DWORD iValue)
{
@@ -2041,7 +2189,7 @@ INT_PTR CProtoIntDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
if (m_hwndStatus) {
RECT rcStatus; GetWindowRect(m_hwndStatus, &rcStatus);
RECT rcClient; GetClientRect(m_hwnd, &rcClient);
- SetWindowPos(m_hwndStatus, NULL, 0, rcClient.bottom-(rcStatus.bottom-rcStatus.top), rcClient.right, (rcStatus.bottom-rcStatus.top), SWP_NOZORDER);
+ SetWindowPos(m_hwndStatus, NULL, 0, rcClient.bottom - (rcStatus.bottom - rcStatus.top), rcClient.right, (rcStatus.bottom - rcStatus.top), SWP_NOZORDER);
UpdateStatusBar();
}
break;
@@ -2103,7 +2251,7 @@ void CProtoIntDlgBase::UpdateStatusBar()
ReleaseDC(m_hwndStatus, hdc);
RECT rcStatus; GetWindowRect(m_hwndStatus, &rcStatus);
- int parts[] = { rcStatus.right-rcStatus.left - sz.cx, -1 };
+ int parts[] = { rcStatus.right - rcStatus.left - sz.cx, -1 };
SendMessage(m_hwndStatus, SB_SETPARTS, 2, (LPARAM)parts);
SendMessage(m_hwndStatus, SB_SETICON, 1, (LPARAM)LoadSkinnedProtoIcon(m_proto_interface->m_szModuleName, m_proto_interface->m_iStatus));
SendMessage(m_hwndStatus, SB_SETTEXT, 1, (LPARAM)m_proto_interface->m_tszUserName);
diff --git a/src/modules/clist/contacts.cpp b/src/modules/clist/contacts.cpp
index d370239c84..204dc3221c 100644
--- a/src/modules/clist/contacts.cpp
+++ b/src/modules/clist/contacts.cpp
@@ -433,66 +433,68 @@ public:
virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
+ TVHITTESTINFO hti;
+
switch (msg) {
case WM_MOUSEMOVE:
- if (dragging) {
- TVHITTESTINFO hti;
- hti.pt.x = (short)LOWORD(lParam);
- hti.pt.y = (short)HIWORD(lParam);
- ClientToScreen(m_hwnd, &hti.pt);
- ScreenToClient(m_nameOrder.GetHwnd(), &hti.pt);
+ if (!dragging)
+ break;
+
+ hti.pt.x = (short)LOWORD(lParam);
+ hti.pt.y = (short)HIWORD(lParam);
+ ClientToScreen(m_hwnd, &hti.pt);
+ ScreenToClient(m_nameOrder.GetHwnd(), &hti.pt);
+ m_nameOrder.HitTest(&hti);
+ if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) {
+ hti.pt.y -= m_nameOrder.GetItemHeight() / 2;
m_nameOrder.HitTest(&hti);
- if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) {
- hti.pt.y -= m_nameOrder.GetItemHeight() / 2;
- m_nameOrder.HitTest(&hti);
- m_nameOrder.SetInsertMark(hti.hItem, 1);
- }
- else {
- if (hti.flags & TVHT_ABOVE) m_nameOrder.SendMsg(WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0);
- if (hti.flags & TVHT_BELOW) m_nameOrder.SendMsg(WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0);
- m_nameOrder.SetInsertMark(NULL, 0);
- }
+ m_nameOrder.SetInsertMark(hti.hItem, 1);
+ }
+ else {
+ if (hti.flags & TVHT_ABOVE) m_nameOrder.SendMsg(WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0);
+ if (hti.flags & TVHT_BELOW) m_nameOrder.SendMsg(WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0);
+ m_nameOrder.SetInsertMark(NULL, 0);
}
break;
case WM_LBUTTONUP:
- if (dragging) {
- m_nameOrder.SetInsertMark(NULL, 0);
- dragging = 0;
- ReleaseCapture();
-
- TVHITTESTINFO hti;
- hti.pt.x = (short)LOWORD(lParam);
- hti.pt.y = (short)HIWORD(lParam);
- ClientToScreen(m_hwnd, &hti.pt);
- ScreenToClient(m_nameOrder.GetHwnd(), &hti.pt);
- hti.pt.y -= m_nameOrder.GetItemHeight() / 2;
- m_nameOrder.HitTest(&hti);
- if (hDragItem == hti.hItem)
- break;
-
- TVITEMEX tvi;
- tvi.mask = TVIF_HANDLE | TVIF_PARAM;
- tvi.hItem = hti.hItem;
- m_nameOrder.GetItem(&tvi);
- if (tvi.lParam == SIZEOF(nameOrderDescr) - 1)
- break;
-
- if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) {
- TCHAR name[128];
- TVINSERTSTRUCT tvis = { 0 };
- tvis.itemex.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT | TVIF_PARAM;
- tvis.itemex.stateMask = 0xFFFFFFFF;
- tvis.itemex.pszText = name;
- tvis.itemex.cchTextMax = SIZEOF(name);
- tvis.itemex.hItem = hDragItem;
- m_nameOrder.GetItem(&tvis.itemex);
- m_nameOrder.DeleteItem(hDragItem);
- tvis.hParent = NULL;
- tvis.hInsertAfter = hti.hItem;
- m_nameOrder.SelectItem(m_nameOrder.InsertItem(&tvis));
- NotifyChange();
- }
+ if (!dragging)
+ break;
+
+ m_nameOrder.SetInsertMark(NULL, 0);
+ dragging = 0;
+ ReleaseCapture();
+
+ hti.pt.x = (short)LOWORD(lParam);
+ hti.pt.y = (short)HIWORD(lParam);
+ ClientToScreen(m_hwnd, &hti.pt);
+ ScreenToClient(m_nameOrder.GetHwnd(), &hti.pt);
+ hti.pt.y -= m_nameOrder.GetItemHeight() / 2;
+ m_nameOrder.HitTest(&hti);
+ if (hDragItem == hti.hItem)
+ break;
+
+ TVITEMEX tvi;
+ tvi.mask = TVIF_HANDLE | TVIF_PARAM;
+ tvi.hItem = hti.hItem;
+ m_nameOrder.GetItem(&tvi);
+ if (tvi.lParam == SIZEOF(nameOrderDescr) - 1)
+ break;
+
+ if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) {
+ TCHAR name[128];
+ TVINSERTSTRUCT tvis = { 0 };
+ tvis.itemex.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT | TVIF_PARAM;
+ tvis.itemex.stateMask = 0xFFFFFFFF;
+ tvis.itemex.pszText = name;
+ tvis.itemex.cchTextMax = SIZEOF(name);
+ tvis.itemex.hItem = hDragItem;
+ m_nameOrder.GetItem(&tvis.itemex);
+ m_nameOrder.DeleteItem(hDragItem);
+ tvis.hParent = NULL;
+ tvis.hInsertAfter = hti.hItem;
+ m_nameOrder.SelectItem(m_nameOrder.InsertItem(&tvis));
+ NotifyChange();
}
break;
}
diff --git a/src/modules/clist/genmenuopt.cpp b/src/modules/clist/genmenuopt.cpp
index 054ac75072..60f8b6962f 100644
--- a/src/modules/clist/genmenuopt.cpp
+++ b/src/modules/clist/genmenuopt.cpp
@@ -41,7 +41,7 @@ struct MenuItemOptData : public MZeroedObject
ptrT defname;
ptrA uniqname;
- bool bShow, bIsSelected;
+ bool bIsSelected;
int id;
PMO_IntMenuItem pimi;
@@ -65,7 +65,7 @@ class CGenMenuOptionsPage : public CDlgBase
TVITEMEX tvi;
tvi.hItem = m_menuItems.GetRoot();
tvi.cchTextMax = SIZEOF(idstr);
- tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_HANDLE;
+ tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_HANDLE | TVIF_IMAGE;
tvi.pszText = idstr;
int count = 0;
@@ -87,7 +87,7 @@ class CGenMenuOptionsPage : public CDlgBase
GetMenuItemName(iod->pimi, menuItemName, sizeof(menuItemName));
mir_snprintf(DBString, SIZEOF(DBString), "%s_visible", menuItemName);
- db_set_b(NULL, MenuNameItems, DBString, iod->bShow);
+ db_set_b(NULL, MenuNameItems, DBString, tvi.iImage != 0);
mir_snprintf(DBString, SIZEOF(DBString), "%s_pos", menuItemName);
db_set_dw(NULL, MenuNameItems, DBString, runtimepos);
@@ -102,7 +102,7 @@ class CGenMenuOptionsPage : public CDlgBase
runtimepos += 100;
}
- if (iod->name && !_tcscmp(iod->name, STR_SEPARATOR) && iod->bShow)
+ if (iod->name && !_tcscmp(iod->name, STR_SEPARATOR) && tvi.iImage)
runtimepos += SEPARATORPOSITIONINTERVAL;
tvi.hItem = m_menuItems.GetNextSibling(tvi.hItem);
@@ -152,7 +152,14 @@ class CGenMenuOptionsPage : public CDlgBase
char menuItemName[256], MenuNameItems[256];
mir_snprintf(MenuNameItems, SIZEOF(MenuNameItems), "%s_Items", pimo->pszName);
- LIST<MenuItemOptData> arItems(20, NumericKeySortT);
+ m_menuItems.SendMsg(WM_SETREDRAW, FALSE, 0);
+ int lastpos = 0;
+ bool bIsFirst = TRUE;
+
+ TVINSERTSTRUCT tvis;
+ tvis.hParent = NULL;
+ tvis.hInsertAfter = TVI_LAST;
+ tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
for (PMO_IntMenuItem p = pimo->m_items.first; p != NULL; p = p->next) {
if (p->mi.root != (HGENMENU)-1 && p->mi.root != NULL)
@@ -175,7 +182,7 @@ class CGenMenuOptionsPage : public CDlgBase
PD->defname = mir_tstrdup(GetMenuItemText(p));
mir_snprintf(buf, SIZEOF(buf), "%s_visible", menuItemName);
- PD->bShow = db_get_b(NULL, MenuNameItems, buf, 1) != 0;
+ int bShow = db_get_b(NULL, MenuNameItems, buf, 1) != 0;
if (bReread) {
mir_snprintf(buf, SIZEOF(buf), "%s_pos", menuItemName);
@@ -188,35 +195,21 @@ class CGenMenuOptionsPage : public CDlgBase
if (p->UniqName)
PD->uniqname = mir_strdup(p->UniqName);
- arItems.insert(PD);
- }
-
- m_menuItems.SendMsg(WM_SETREDRAW, FALSE, 0);
- int lastpos = 0;
- bool bIsFirst = TRUE;
+ if (PD->pos - lastpos >= SEPARATORPOSITIONINTERVAL) {
+ MenuItemOptData *sep = new MenuItemOptData();
+ sep->id = -1;
+ sep->name = mir_tstrdup(STR_SEPARATOR);
+ sep->pos = PD->pos - 1;
- TVINSERTSTRUCT tvis;
- tvis.hParent = NULL;
- tvis.hInsertAfter = TVI_LAST;
- tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
- for (int i = 0; i < arItems.getCount(); i++) {
- auto p = arItems[i];
- if (p->pos - lastpos >= SEPARATORPOSITIONINTERVAL) {
- MenuItemOptData *PD = new MenuItemOptData();
- PD->id = -1;
- PD->name = mir_tstrdup(STR_SEPARATOR);
- PD->pos = p->pos - 1;
- PD->bShow = true;
-
- tvis.item.lParam = (LPARAM)PD;
- tvis.item.pszText = PD->name;
- tvis.item.iImage = tvis.item.iSelectedImage = PD->bShow;
+ tvis.item.lParam = (LPARAM)sep;
+ tvis.item.pszText = sep->name;
+ tvis.item.iImage = tvis.item.iSelectedImage = 1;
m_menuItems.InsertItem(&tvis);
}
- tvis.item.lParam = (LPARAM)p;
- tvis.item.pszText = p->name;
- tvis.item.iImage = tvis.item.iSelectedImage = p->bShow;
+ tvis.item.lParam = (LPARAM)PD;
+ tvis.item.pszText = PD->name;
+ tvis.item.iImage = tvis.item.iSelectedImage = bShow;
HTREEITEM hti = m_menuItems.InsertItem(&tvis);
if (bIsFirst) {
@@ -224,7 +217,7 @@ class CGenMenuOptionsPage : public CDlgBase
bIsFirst = false;
}
- lastpos = p->pos;
+ lastpos = PD->pos;
}
m_menuItems.SendMsg(WM_SETREDRAW, TRUE, 0);
@@ -252,7 +245,7 @@ class CGenMenuOptionsPage : public CDlgBase
HTREEITEM MoveItemAbove(HTREEITEM hItem, HTREEITEM hInsertAfter)
{
TVITEMEX tvi = { 0 };
- tvi.mask = TVIF_HANDLE | TVIF_PARAM;
+ tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_IMAGE;
tvi.hItem = hItem;
if (!m_menuItems.GetItem(&tvi))
return NULL;
@@ -268,7 +261,7 @@ class CGenMenuOptionsPage : public CDlgBase
tvis.itemex.pszText = name;
tvis.itemex.cchTextMax = SIZEOF(name);
tvis.itemex.hItem = hItem;
- tvis.itemex.iImage = tvis.itemex.iSelectedImage = ((MenuItemOptData*)tvi.lParam)->bShow;
+ tvis.itemex.iImage = tvis.itemex.iSelectedImage = tvi.iImage;
if (!m_menuItems.GetItem(&tvis.itemex))
return NULL;
@@ -309,7 +302,8 @@ public:
m_btnDefault.OnClick = Callback(this, &CGenMenuOptionsPage::btnDefault_Clicked);
m_menuObjects.OnSelChanged = Callback(this, &CGenMenuOptionsPage::onMenuObjectChanged);
-
+
+ m_menuItems.SetFlags(MTREE_CHECKBOX);
m_menuItems.OnSelChanged = Callback(this, &CGenMenuOptionsPage::onMenuItemChanged);
m_menuItems.OnBeginDrag = Callback(this, &CGenMenuOptionsPage::onMenuItemBeginDrag);
}
@@ -386,13 +380,12 @@ public:
MenuItemOptData *PD = new MenuItemOptData();
PD->id = -1;
PD->name = mir_tstrdup(STR_SEPARATOR);
- PD->bShow = true;
PD->pos = ((MenuItemOptData *)tvi.lParam)->pos - 1;
TVINSERTSTRUCT tvis = { 0 };
tvis.item.lParam = (LPARAM)(PD);
tvis.item.pszText = PD->name;
- tvis.item.iImage = tvis.item.iSelectedImage = PD->bShow;
+ tvis.item.iImage = tvis.item.iSelectedImage = 1;
tvis.hInsertAfter = hti;
tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
m_menuItems.InsertItem(&tvis);
@@ -559,20 +552,6 @@ public:
return 0;
}
- void OnClickCheckbox(HTREEITEM hItem)
- {
- TVITEMEX tvi;
- tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
- tvi.hItem = hItem;
- m_menuItems.GetItem(&tvi);
-
- tvi.iImage = tvi.iSelectedImage = !tvi.iImage;
- ((MenuItemOptData *)tvi.lParam)->bShow = tvi.iImage != 0;
- m_menuItems.SetItem(&tvi);
-
- NotifyChange();
- }
-
virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
TVHITTESTINFO hti;
@@ -669,11 +648,6 @@ public:
SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, onMenuItemDraw((LPNMTVCUSTOMDRAW)phdr));
return TRUE;
- case TVN_KEYDOWN:
- if (((LPNMLVKEYDOWN)phdr)->wVKey == VK_SPACE)
- OnClickCheckbox(m_menuItems.GetSelection());
- break;
-
case NM_CLICK:
TVHITTESTINFO hti;
hti.pt.x = (short)LOWORD(GetMessagePos());
@@ -682,9 +656,6 @@ public:
if (!m_menuItems.HitTest(&hti))
break;
- if (hti.flags & TVHT_ONITEMICON)
- OnClickCheckbox(hti.hItem);
-
/*--------MultiSelection----------*/
if (hti.flags & TVHT_ONITEMLABEL) {
/// LabelClicked Set/unset selection
diff --git a/src/modules/clist/protocolorder.cpp b/src/modules/clist/protocolorder.cpp
index bab4380b61..a454793de3 100644
--- a/src/modules/clist/protocolorder.cpp
+++ b/src/modules/clist/protocolorder.cpp
@@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
struct ProtocolData
{
char *RealName;
- int show, enabled;
+ int enabled;
};
int isProtoSuitable(PROTO_INTERFACE* ppi)
@@ -125,11 +125,10 @@ class CProtocolOrderOpts : public CDlgBase
ProtocolData *PD = (ProtocolData*)mir_alloc(sizeof(ProtocolData));
PD->RealName = pa->szModuleName;
PD->enabled = Proto_IsAccountEnabled(pa) && isProtoSuitable(pa->ppro);
- PD->show = PD->enabled ? pa->bIsVisible : 100;
tvis.item.lParam = (LPARAM)PD;
tvis.item.pszText = pa->tszAccountName;
- tvis.item.iImage = tvis.item.iSelectedImage = PD->show;
+ tvis.item.iImage = tvis.item.iSelectedImage = PD->enabled ? pa->bIsVisible : 100;
m_order.InsertItem(&tvis);
}
}
@@ -150,6 +149,7 @@ public:
{
m_btnReset.OnClick = Callback(this, &CProtocolOrderOpts::onReset_Click);
+ m_order.SetFlags(MTREE_CHECKBOX);
m_order.OnBeginDrag = Callback(this, &CProtocolOrderOpts::onOrder_BeginDrag);
m_order.OnDeleteItem = Callback(this, &CProtocolOrderOpts::onOrder_DeleteItem);
}
@@ -170,7 +170,7 @@ public:
TVITEMEX tvi;
tvi.hItem = m_order.GetRoot();
- tvi.mask = TVIF_PARAM | TVIF_HANDLE;
+ tvi.mask = TVIF_PARAM | TVIF_HANDLE | TVIF_IMAGE;
while (tvi.hItem != NULL) {
m_order.GetItem(&tvi);
@@ -182,7 +182,7 @@ public:
idx++;
pa->iOrder = idx++;
if (ppd->enabled)
- pa->bIsVisible = ppd->show != 0;
+ pa->bIsVisible = tvi.iImage != 0;
}
}
@@ -230,31 +230,6 @@ public:
TVHITTESTINFO hti;
switch (msg) {
- case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->code) {
- case NM_CLICK:
- hti.pt.x = (short)LOWORD(GetMessagePos());
- hti.pt.y = (short)HIWORD(GetMessagePos());
- ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt);
- if (m_order.HitTest(&hti)) {
- if (hti.flags & TVHT_ONITEMICON) {
- TVITEMEX tvi;
- tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
- tvi.hItem = hti.hItem;
- m_order.GetItem(&tvi);
-
- ProtocolData *pData = (ProtocolData*)tvi.lParam;
- if (pData->enabled) {
- tvi.iImage = tvi.iSelectedImage = !tvi.iImage;
- pData->show = tvi.iImage;
- m_order.SetItem(&tvi);
- NotifyChange();
- }
- }
- }
- }
- break;
-
case WM_MOUSEMOVE:
if (!m_bDragging)
break;
@@ -300,7 +275,7 @@ public:
hti.hItem = TVI_FIRST;
TVITEMEX tvi;
- tvi.mask = TVIF_HANDLE | TVIF_PARAM;
+ tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_IMAGE;
tvi.hItem = m_hDragItem;
m_order.GetItem(&tvi);
if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT) || (hti.hItem == TVI_FIRST)) {
@@ -311,7 +286,7 @@ public:
tvis.itemex.pszText = name;
tvis.itemex.cchTextMax = SIZEOF(name);
tvis.itemex.hItem = m_hDragItem;
- tvis.itemex.iImage = tvis.itemex.iSelectedImage = ((ProtocolData *)tvi.lParam)->show;
+ tvis.itemex.iImage = tvis.itemex.iSelectedImage = tvi.iImage;
m_order.GetItem(&tvis.itemex);
// the pointed lParam will be freed inside TVN_DELETEITEM