diff options
author | George Hazan <george.hazan@gmail.com> | 2015-05-17 23:09:42 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-05-17 23:09:42 +0000 |
commit | e833aea07ac8bd91fbde3cae75fd81f3fd09974b (patch) | |
tree | ae8542f848edf7134539007b42c4f51d510ce33f /src/mir_core | |
parent | 127a156c3d759bf71d887331f1dba440d8dcddf7 (diff) |
code of MTREE_MULTISELECT + MTREE_DND merged and adapted to the core
git-svn-id: http://svn.miranda-ng.org/main/trunk@13669 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/mir_core')
-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 | 295 |
3 files changed, 158 insertions, 139 deletions
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index d59ce8407b..489473cc41 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -1090,3 +1090,4 @@ Proto_RegisterModule @1074 NONAME ?SelectRange@CCtrlTreeView@@QAEXPAU_TREEITEM@@0@Z @1091 NONAME
?Unselect@CCtrlTreeView@@QAEXPAU_TREEITEM@@@Z @1092 NONAME
?UnselectAll@CCtrlTreeView@@QAEXXZ @1093 NONAME
+?MoveItemAbove@CCtrlTreeView@@AAEPAU_TREEITEM@@PAU2@0@Z @1094 NONAME
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index 67bbf17e90..cd8e726c37 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -1090,3 +1090,4 @@ Proto_RegisterModule @1074 NONAME ?SelectRange@CCtrlTreeView@@QEAAXPEAU_TREEITEM@@0@Z @1091 NONAME
?Unselect@CCtrlTreeView@@QEAAXPEAU_TREEITEM@@@Z @1092 NONAME
?UnselectAll@CCtrlTreeView@@QEAAXXZ @1093 NONAME
+?MoveItemAbove@CCtrlTreeView@@AEAAPEAU_TREEITEM@@PEAU2@0@Z @1094 NONAME
diff --git a/src/mir_core/src/ui_utils.cpp b/src/mir_core/src/ui_utils.cpp index 24f2cc5d6d..e2270d0fcb 100644 --- a/src/mir_core/src/ui_utils.cpp +++ b/src/mir_core/src/ui_utils.cpp @@ -41,8 +41,8 @@ static LIST<CCtrlBase> arControls(10, CompareControls); #pragma comment(lib, "uxtheme")
-CDlgBase::CDlgBase(HINSTANCE hInst, int idDialog) :
- m_controls(1, CCtrlBase::cmp)
+CDlgBase::CDlgBase(HINSTANCE hInst, int idDialog)
+ : m_controls(1, CCtrlBase::cmp)
{
m_hInst = hInst;
m_idDialog = idDialog;
@@ -91,7 +91,7 @@ void CDlgBase::SetCaption(const TCHAR *ptszCaption) int CDlgBase::Resizer(UTILRESIZECONTROL*)
{
- return RD_ANCHORX_LEFT|RD_ANCHORY_TOP;
+ return RD_ANCHORX_LEFT | RD_ANCHORY_TOP;
}
INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
@@ -150,12 +150,11 @@ INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) if (idCode == BN_CLICKED &&
((idCtrl == IDOK) && (m_autoClose & CLOSE_ON_OK) ||
- (idCtrl == IDCANCEL) && (m_autoClose & CLOSE_ON_CANCEL)))
- {
+ (idCtrl == IDCANCEL) && (m_autoClose & CLOSE_ON_CANCEL))) {
PostMessage(m_hwnd, WM_CLOSE, 0, 0);
}
- return FALSE;
}
+ return FALSE;
case WM_NOTIFY:
{
@@ -174,8 +173,8 @@ INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) if (CCtrlBase *ctrl = FindControl(pnmh->idFrom))
return ctrl->OnNotify(idCtrl, pnmh);
- return FALSE;
}
+ return FALSE;
case WM_SIZE:
if (m_forceResizable || (GetWindowLongPtr(m_hwnd, GWL_STYLE) & WS_SIZEBOX)) {
@@ -228,7 +227,7 @@ INT_PTR CALLBACK CDlgBase::GlobalDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPA if (msg == WM_INITDIALOG) {
wnd = (CDlgBase*)lParam;
wnd->m_hwnd = hwnd;
-
+
mir_cslock lck(csDialogs);
arDialogs.insert(wnd);
}
@@ -255,7 +254,7 @@ void CDlgBase::AddControl(CCtrlBase *ctrl) void CDlgBase::NotifyControls(void (CCtrlBase::*fn)())
{
- for (int i=0; i < m_controls.getCount(); i++)
+ for (int i = 0; i < m_controls.getCount(); i++)
(m_controls[i]->*fn)();
}
@@ -275,10 +274,9 @@ CDlgBase* CDlgBase::Find(HWND hwnd) /////////////////////////////////////////////////////////////////////////////////////////
// CCtrlCombo class
-CCtrlCombo::CCtrlCombo(CDlgBase* dlg, int ctrlId) :
- CCtrlData(dlg, ctrlId)
-{
-}
+CCtrlCombo::CCtrlCombo(CDlgBase* dlg, int ctrlId)
+ : CCtrlData(dlg, ctrlId)
+{}
BOOL CCtrlCombo::OnCommand(HWND, WORD, WORD idCode)
{
@@ -415,9 +413,8 @@ void CCtrlCombo::ShowDropdown(bool show) // CCtrlListBox class
CCtrlListBox::CCtrlListBox(CDlgBase* dlg, int ctrlId) :
- CCtrlBase(dlg, ctrlId)
-{
-}
+CCtrlBase(dlg, ctrlId)
+{}
BOOL CCtrlListBox::OnCommand(HWND, WORD, WORD idCode)
{
@@ -524,10 +521,9 @@ void CCtrlListBox::SetSel(int index, bool sel) /////////////////////////////////////////////////////////////////////////////////////////
// CCtrlCheck class
-CCtrlCheck::CCtrlCheck(CDlgBase* dlg, int ctrlId) :
- CCtrlData(dlg, ctrlId)
-{
-}
+CCtrlCheck::CCtrlCheck(CDlgBase* dlg, int ctrlId)
+ : CCtrlData(dlg, ctrlId)
+{}
BOOL CCtrlCheck::OnCommand(HWND, WORD, WORD)
{
@@ -558,10 +554,9 @@ void CCtrlCheck::SetState(int state) /////////////////////////////////////////////////////////////////////////////////////////
// CCtrlEdit class
-CCtrlEdit::CCtrlEdit(CDlgBase* dlg, int ctrlId) :
- CCtrlData(dlg, ctrlId)
-{
-}
+CCtrlEdit::CCtrlEdit(CDlgBase* dlg, int ctrlId)
+ : CCtrlData(dlg, ctrlId)
+{}
BOOL CCtrlEdit::OnCommand(HWND, WORD, WORD idCode)
{
@@ -596,11 +591,10 @@ void CCtrlEdit::OnReset() /////////////////////////////////////////////////////////////////////////////////////////
// CCtrlData class
-CCtrlData::CCtrlData(CDlgBase *wnd, int idCtrl) :
- CCtrlBase(wnd, idCtrl),
+CCtrlData::CCtrlData(CDlgBase *wnd, int idCtrl)
+ : CCtrlBase(wnd, idCtrl),
m_dbLink(NULL)
-{
-}
+{}
CCtrlData::~CCtrlData()
{
@@ -627,19 +621,17 @@ void CCtrlData::CreateDbLink(const char* szModuleName, const char* szSetting, TC /////////////////////////////////////////////////////////////////////////////////////////
// CCtrlMButton
-CCtrlMButton::CCtrlMButton(CDlgBase* dlg, int ctrlId, HICON hIcon, const char* tooltip) :
- CCtrlButton(dlg, ctrlId),
+CCtrlMButton::CCtrlMButton(CDlgBase* dlg, int ctrlId, HICON hIcon, const char* tooltip)
+ : CCtrlButton(dlg, ctrlId),
m_hIcon(hIcon),
m_toolTip(tooltip)
-{
-}
+{}
-CCtrlMButton::CCtrlMButton(CDlgBase* dlg, int ctrlId, int iCoreIcon, const char* tooltip) :
- CCtrlButton(dlg, ctrlId),
+CCtrlMButton::CCtrlMButton(CDlgBase* dlg, int ctrlId, int iCoreIcon, const char* tooltip)
+ : CCtrlButton(dlg, ctrlId),
m_hIcon(::LoadSkinnedIcon(iCoreIcon)),
m_toolTip(tooltip)
-{
-}
+{}
CCtrlMButton::~CCtrlMButton()
{
@@ -668,10 +660,9 @@ void CCtrlMButton::MakePush() /////////////////////////////////////////////////////////////////////////////////////////
// CCtrlButton
-CCtrlButton::CCtrlButton(CDlgBase* wnd, int idCtrl) :
- CCtrlBase(wnd, idCtrl)
-{
-}
+CCtrlButton::CCtrlButton(CDlgBase* wnd, int idCtrl)
+ : CCtrlBase(wnd, idCtrl)
+{}
BOOL CCtrlButton::OnCommand(HWND, WORD, WORD idCode)
{
@@ -683,11 +674,10 @@ BOOL CCtrlButton::OnCommand(HWND, WORD, WORD idCode) /////////////////////////////////////////////////////////////////////////////////////////
// CCtrlHyperlink
-CCtrlHyperlink::CCtrlHyperlink(CDlgBase* wnd, int idCtrl, const char* url) :
- CCtrlBase(wnd, idCtrl),
+CCtrlHyperlink::CCtrlHyperlink(CDlgBase* wnd, int idCtrl, const char* url)
+ : CCtrlBase(wnd, idCtrl),
m_url(url)
-{
-}
+{}
BOOL CCtrlHyperlink::OnCommand(HWND, WORD, WORD)
{
@@ -697,10 +687,9 @@ BOOL CCtrlHyperlink::OnCommand(HWND, WORD, WORD) /////////////////////////////////////////////////////////////////////////////////////////
// CCtrlClc
-CCtrlClc::CCtrlClc(CDlgBase* dlg, int ctrlId):
- CCtrlBase(dlg, ctrlId)
-{
-}
+CCtrlClc::CCtrlClc(CDlgBase* dlg, int ctrlId)
+ : CCtrlBase(dlg, ctrlId)
+{}
BOOL CCtrlClc::OnNotify(int, NMHDR *pnmh)
{
@@ -910,10 +899,9 @@ void CCtrlClc::SetTextColor(int iFontId, COLORREF clText) /////////////////////////////////////////////////////////////////////////////////////////
// CCtrlListView
-CCtrlListView::CCtrlListView(CDlgBase* dlg, int ctrlId) :
- CCtrlBase(dlg, ctrlId)
-{
-}
+CCtrlListView::CCtrlListView(CDlgBase* dlg, int ctrlId)
+ : CCtrlBase(dlg, ctrlId)
+{}
BOOL CCtrlListView::OnNotify(int, NMHDR *pnmh)
{
@@ -933,7 +921,6 @@ BOOL CCtrlListView::OnNotify(int, NMHDR *pnmh) case LVN_GETDISPINFO: OnGetDispInfo(&evt); return TRUE;
case LVN_GETINFOTIP: OnGetInfoTip(&evt); return TRUE;
case LVN_HOTTRACK: OnHotTrack(&evt); return TRUE;
- //case LVN_INCREMENTALSEARCH: OnIncrementalSearch(&evt); return TRUE;
case LVN_INSERTITEM: OnInsertItem(&evt); return TRUE;
case LVN_ITEMACTIVATE: OnItemActivate(&evt); return TRUE;
case LVN_ITEMCHANGED: OnItemChanged(&evt); return TRUE;
@@ -971,7 +958,7 @@ void CCtrlListView::AddColumn(int iSubItem, TCHAR *name, int cx) void CCtrlListView::AddGroup(int iGroupId, TCHAR *name)
{
- LVGROUP lvg = {0};
+ LVGROUP lvg = { 0 };
lvg.cbSize = sizeof(lvg);
lvg.mask = LVGF_HEADER | LVGF_GROUPID;
lvg.pszHeader = name;
@@ -982,7 +969,7 @@ void CCtrlListView::AddGroup(int iGroupId, TCHAR *name) int CCtrlListView::AddItem(TCHAR *text, int iIcon, LPARAM lParam, int iGroupId)
{
- LVITEM lvi = {0};
+ LVITEM lvi = { 0 };
lvi.mask = LVIF_PARAM | LVIF_TEXT | LVIF_IMAGE;
lvi.iSubItem = 0;
lvi.pszText = text;
@@ -998,7 +985,7 @@ int CCtrlListView::AddItem(TCHAR *text, int iIcon, LPARAM lParam, int iGroupId) void CCtrlListView::SetItem(int iItem, int iSubItem, TCHAR *text, int iIcon)
{
- LVITEM lvi = {0};
+ LVITEM lvi = { 0 };
lvi.mask = LVIF_TEXT;
lvi.iItem = iItem;
lvi.iSubItem = iSubItem;
@@ -1013,7 +1000,7 @@ void CCtrlListView::SetItem(int iItem, int iSubItem, TCHAR *text, int iIcon) LPARAM CCtrlListView::GetItemData(int iItem)
{
- LVITEM lvi = {0};
+ LVITEM lvi = { 0 };
lvi.mask = LVIF_PARAM;
lvi.iItem = iItem;
GetItem(&lvi);
@@ -1364,11 +1351,10 @@ BOOL CCtrlListView::Update(int iItem) /////////////////////////////////////////////////////////////////////////////////////////
// CCtrlTreeView
-CCtrlTreeView::CCtrlTreeView(CDlgBase* dlg, int ctrlId):
- CCtrlBase(dlg, ctrlId),
+CCtrlTreeView::CCtrlTreeView(CDlgBase* dlg, int ctrlId)
+ : CCtrlBase(dlg, ctrlId),
m_dwFlags(0)
-{
-}
+{}
void CCtrlTreeView::SetFlags(uint32_t dwFlags)
{
@@ -1393,6 +1379,45 @@ void CCtrlTreeView::OnInit() Subclass();
}
+HTREEITEM CCtrlTreeView::MoveItemAbove(HTREEITEM hItem, HTREEITEM hInsertAfter)
+{
+ TVITEMEX tvi = { 0 };
+ tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_IMAGE;
+ tvi.hItem = hItem;
+ if (!GetItem(&tvi))
+ return NULL;
+
+ if (hItem == NULL || hInsertAfter == NULL)
+ return NULL;
+
+ if (hItem == hInsertAfter)
+ return hItem;
+
+ TCHAR name[128];
+ TVINSERTSTRUCT tvis = { 0 };
+ tvis.itemex.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
+ tvis.itemex.pszText = name;
+ tvis.itemex.cchTextMax = SIZEOF(name);
+ tvis.itemex.hItem = hItem;
+ tvis.itemex.iImage = tvis.itemex.iSelectedImage = tvi.iImage;
+ if (!GetItem(&tvis.itemex))
+ return NULL;
+
+ // the pointed lParam will be freed inside TVN_DELETEITEM
+ // so lets substitute it with 0
+ LPARAM saveOldData = tvis.itemex.lParam;
+ tvis.itemex.lParam = 0;
+ SetItem(&tvis.itemex);
+
+ // now current item contain lParam = 0 we can delete it. the memory will be kept.
+ DeleteItem(hItem);
+
+ tvis.itemex.lParam = saveOldData;
+ tvis.hParent = NULL;
+ tvis.hInsertAfter = hInsertAfter;
+ return InsertItem(&tvis);
+}
+
LRESULT CCtrlTreeView::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
TVHITTESTINFO hti;
@@ -1437,37 +1462,27 @@ LRESULT CCtrlTreeView::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lParam) else if (hti.flags & TVHT_BELOW)
hti.hItem = TVI_LAST;
- TVITEMEX tvi;
- tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_IMAGE;
- tvi.hItem = m_hDragItem;
- GetItem(&tvi);
- if ((hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) || hti.hItem == TVI_FIRST) {
- TCHAR name[128];
- TVINSERTSTRUCT tvis = { 0 };
- tvis.itemex.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
- tvis.itemex.stateMask = 0xFFFFFFFF;
- tvis.itemex.pszText = name;
- tvis.itemex.cchTextMax = SIZEOF(name);
- tvis.itemex.hItem = m_hDragItem;
- tvis.itemex.iImage = tvis.itemex.iSelectedImage = tvi.iImage;
- GetItem(&tvis.itemex);
-
- // the pointed lParam will be freed inside TVN_DELETEITEM
- // so lets substitute it with 0
- LPARAM saveOldData = tvis.itemex.lParam;
- tvis.itemex.lParam = 0;
- SetItem(&tvis.itemex);
-
- // now current item contain lParam = 0 we can delete it. the memory will be kept.
- tvis.itemex.lParam = saveOldData;
- DeleteItem(m_hDragItem);
-
- tvis.hParent = NULL;
- tvis.hInsertAfter = hti.hItem;
- SelectItem(InsertItem(&tvis));
+ HTREEITEM FirstItem = NULL;
+ if (m_bMultiSelect) {
+ LIST<_TREEITEM> arItems(10);
+ GetSelected(arItems);
- NotifyChange();
+ // Proceed moving
+ HTREEITEM insertAfter = hti.hItem;
+ for (int i = 0; i < arItems.getCount(); i++) {
+ if (!insertAfter)
+ break;
+
+ insertAfter = MoveItemAbove(arItems[i], insertAfter);
+ if (!i)
+ FirstItem = insertAfter;
+ }
}
+ else FirstItem = MoveItemAbove(m_hDragItem, hti.hItem);
+ if (FirstItem)
+ SelectItem(FirstItem);
+
+ NotifyChange();
}
break;
@@ -1482,11 +1497,12 @@ LRESULT CCtrlTreeView::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lParam) break;
}
- if (!(wParam & (MK_CONTROL | MK_SHIFT)) || !(hti.flags & (TVHT_ONITEMICON | TVHT_ONITEMLABEL | TVHT_ONITEMRIGHT))) {
- UnselectAll();
- TreeView_SelectItem(m_hwnd, hti.hItem);
- break;
- }
+ if (!m_bDndEnabled)
+ if (!(wParam & (MK_CONTROL | MK_SHIFT)) || !(hti.flags & (TVHT_ONITEMICON | TVHT_ONITEMLABEL | TVHT_ONITEMRIGHT))) {
+ UnselectAll();
+ TreeView_SelectItem(m_hwnd, hti.hItem);
+ break;
+ }
if (wParam & MK_CONTROL) {
LIST<_TREEITEM> selected(1);
@@ -1524,7 +1540,7 @@ LRESULT CCtrlTreeView::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lParam) Select(selected);
SelectRange(hItem, hti.hItem);
}
- return 0;
+ break;
}
return CSuper::CustomWndProc(msg, wParam, lParam);
@@ -1553,19 +1569,19 @@ BOOL CCtrlTreeView::OnNotify(int, NMHDR *pnmh) // user-defined can clear the event code to disable dragging
if (m_bDndEnabled && pnmh->code) {
- ::SetCapture(m_hwnd); - m_bDragging = true; - m_hDragItem = evt.nmtv->itemNew.hItem; - SelectItem(m_hDragItem); - } + ::SetCapture(m_hwnd);
+ m_bDragging = true;
+ m_hDragItem = evt.nmtv->itemNew.hItem;
+ SelectItem(m_hDragItem);
+ }
return TRUE;
case TVN_KEYDOWN:
if (evt.nmtvkey->wVKey == VK_SPACE) {
if (m_bCheckBox)
- InvertCheck(GetSelection()); + InvertCheck(GetSelection());
NotifyChange();
- } + }
OnKeyDown(&evt);
return TRUE;
@@ -1575,14 +1591,14 @@ BOOL CCtrlTreeView::OnNotify(int, NMHDR *pnmh) TVHITTESTINFO hti;
hti.pt.x = (short)LOWORD(GetMessagePos());
hti.pt.y = (short)HIWORD(GetMessagePos());
- ScreenToClient(pnmh->hwndFrom, &hti.pt); - if (HitTest(&hti)) { - if (m_bCheckBox && (hti.flags & TVHT_ONITEMICON) || !m_bCheckBox && (hti.flags & TVHT_ONITEMSTATEICON)) { - if (m_bCheckBox) - InvertCheck(hti.hItem); + ScreenToClient(pnmh->hwndFrom, &hti.pt);
+ if (HitTest(&hti)) {
+ if (m_bCheckBox && (hti.flags & TVHT_ONITEMICON) || !m_bCheckBox && (hti.flags & TVHT_ONITEMSTATEICON)) {
+ if (m_bCheckBox)
+ InvertCheck(hti.hItem);
NotifyChange();
}
- } + }
}
return FALSE;
@@ -1590,14 +1606,14 @@ BOOL CCtrlTreeView::OnNotify(int, NMHDR *pnmh) 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); + 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);
}
void CCtrlTreeView::TranslateItem(HTREEITEM hItem)
@@ -1635,7 +1651,7 @@ void CCtrlTreeView::TranslateTree() HTREEITEM CCtrlTreeView::FindNamedItem(HTREEITEM hItem, const TCHAR *name)
{
- TVITEMEX tvi = {0};
+ TVITEMEX tvi = { 0 };
TCHAR str[MAX_PATH];
if (hItem)
@@ -1664,7 +1680,7 @@ HTREEITEM CCtrlTreeView::FindNamedItem(HTREEITEM hItem, const TCHAR *name) void CCtrlTreeView::GetItem(HTREEITEM hItem, TVITEMEX *tvi)
{
memset(tvi, 0, sizeof(*tvi));
- tvi->mask = TVIF_CHILDREN|TVIF_HANDLE|TVIF_IMAGE|TVIF_INTEGRAL|TVIF_PARAM|TVIF_SELECTEDIMAGE|TVIF_STATE;
+ tvi->mask = TVIF_CHILDREN | TVIF_HANDLE | TVIF_IMAGE | TVIF_INTEGRAL | TVIF_PARAM | TVIF_SELECTEDIMAGE | TVIF_STATE;
tvi->hItem = hItem;
GetItem(tvi);
}
@@ -1672,7 +1688,7 @@ void CCtrlTreeView::GetItem(HTREEITEM hItem, TVITEMEX *tvi) void CCtrlTreeView::GetItem(HTREEITEM hItem, TVITEMEX *tvi, TCHAR *szText, int iTextLength)
{
memset(tvi, 0, sizeof(*tvi));
- tvi->mask = TVIF_CHILDREN|TVIF_HANDLE|TVIF_IMAGE|TVIF_INTEGRAL|TVIF_PARAM|TVIF_SELECTEDIMAGE|TVIF_STATE|TVIF_TEXT;
+ tvi->mask = TVIF_CHILDREN | TVIF_HANDLE | TVIF_IMAGE | TVIF_INTEGRAL | TVIF_PARAM | TVIF_SELECTEDIMAGE | TVIF_STATE | TVIF_TEXT;
tvi->hItem = hItem;
tvi->pszText = szText;
tvi->cchTextMax = iTextLength;
@@ -1728,9 +1744,7 @@ void CCtrlTreeView::UnselectAll() void CCtrlTreeView::SelectRange(HTREEITEM hStart, HTREEITEM hEnd)
{
- int start = 0;
- int end = 0;
- int i = 0;
+ int start = 0, end = 0, i = 0;
HTREEITEM hItem = TreeView_GetRoot(m_hwnd);
while (hItem) {
if (hItem == hStart)
@@ -2025,10 +2039,11 @@ void CCtrlTreeView::SortChildrenCB(TVSORTCB *cb, BOOL fRecurse) /////////////////////////////////////////////////////////////////////////////////////////
// CCtrlPages
-CCtrlPages::CCtrlPages(CDlgBase* dlg, int ctrlId):
- CCtrlBase(dlg, ctrlId), m_hIml(NULL), m_pActivePage(NULL)
-{
-}
+CCtrlPages::CCtrlPages(CDlgBase* dlg, int ctrlId)
+ : CCtrlBase(dlg, ctrlId),
+ m_hIml(NULL),
+ m_pActivePage(NULL)
+{}
void CCtrlPages::OnInit()
{
@@ -2082,11 +2097,14 @@ void CCtrlPages::AttachDialog(int iPage, CDlgBase *pDlg) info->m_pDlg->Close();
info->m_pDlg = pDlg;
- //SetParent(info->m_pDlg->GetHwnd(), m_hwnd);
+ if (pDlg->GetHwnd() == NULL) {
+ pDlg->SetParent(m_hwnd);
+ pDlg->Create();
+ }
if (iPage == TabCtrl_GetCurSel(m_hwnd)) {
- m_pActivePage = info->m_pDlg;
- ShowPage(info->m_pDlg);
+ m_pActivePage = pDlg;
+ ShowPage(pDlg);
}
}
}
@@ -2098,14 +2116,14 @@ void CCtrlPages::ShowPage(CDlgBase *pDlg) RECT rc;
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);
+
+ EnableThemeDialogTexture(pDlg->GetHwnd(), ETDT_ENABLETAB);
+ SetWindowPos(pDlg->GetHwnd(), HWND_TOP, rc.left, rc.top, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
}
void CCtrlPages::ActivatePage(int iPage)
{
TabCtrl_SetCurSel(m_hwnd, iPage);
- //ShowPage(iPage);
}
BOOL CCtrlPages::OnNotify(int /*idCtrl*/, NMHDR *pnmh)
@@ -2205,8 +2223,7 @@ void CCtrlBase::OnApply() }
void CCtrlBase::OnReset()
-{
-}
+{}
void CCtrlBase::Enable(int bIsEnable)
{
@@ -2222,7 +2239,7 @@ void CCtrlBase::NotifyChange() {
if (!m_parentWnd || m_parentWnd->IsInitialized())
m_bChanged = true;
-
+
if (m_parentWnd) {
m_parentWnd->OnChange(this);
if (m_parentWnd->IsInitialized())
@@ -2405,8 +2422,7 @@ CProtoIntDlgBase::CProtoIntDlgBase(PROTO_INTERFACE *proto, int idDialog, bool sh m_proto_interface(proto),
m_show_label(show_label),
m_hwndStatus(NULL)
-{
-}
+{}
void CProtoIntDlgBase::CreateLink(CCtrlData& ctrl, char *szSetting, BYTE type, DWORD iValue)
{
@@ -2490,7 +2506,8 @@ INT_PTR CProtoIntDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) void CProtoIntDlgBase::UpdateProtoTitle(const TCHAR *szText)
{
- if (!m_show_label) return;
+ if (!m_show_label)
+ return;
int curLength;
const TCHAR *curText;
|