本文整理汇总了C++中COptItem_TreeCtrl::GetSelectedItemID方法的典型用法代码示例。如果您正苦于以下问题:C++ COptItem_TreeCtrl::GetSelectedItemID方法的具体用法?C++ COptItem_TreeCtrl::GetSelectedItemID怎么用?C++ COptItem_TreeCtrl::GetSelectedItemID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类COptItem_TreeCtrl
的用法示例。
在下文中一共展示了COptItem_TreeCtrl::GetSelectedItemID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DeleteSelectedItem
bool CMsgTree::DeleteSelectedItem() // returns true if the item was deleted
{
COptItem_TreeCtrl *TreeCtrl = GetTreeCtrl();
int Order = TreeCtrl->IDToOrder(TreeCtrl->GetSelectedItemID(GetParent(hTreeView)));
_ASSERT(Order >= 0);
CTreeItem *SelectedItem = &TreeCtrl->Value[Order];
//NightFox: fix for langpack and fix cut char space in text
if (MessageBox(GetParent(hTreeView),
((SelectedItem->Flags & TIF_GROUP) ?
TranslateT("Do you really want to delete this category with its messages?") :
TranslateT("Do you really want to delete this message?")),
TranslateT("New Away System"), MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2) == IDYES) {
NMMSGTREE nm = { 0 };
nm.ItemOld = SelectedItem;
nm.hdr.code = MTN_DELETEITEM;
nm.hdr.hwndFrom = hTreeView;
nm.hdr.idFrom = GetDlgCtrlID(hTreeView);
if (!SendMessage(GetParent(hTreeView), WM_NOTIFY, 0, (LPARAM)&nm)) {
TreeCtrl->Delete(GetParent(hTreeView), TreeCtrl->GetSelectedItemID(GetParent(hTreeView)));
return true;
}
}
return false;
}
示例2: GetSelection
CBaseTreeItem* CMsgTree::GetSelection() // returns NULL if there's nothing selected
{
COptItem_TreeCtrl *TreeCtrl = GetTreeCtrl();
int Order = TreeCtrl->IDToOrder(TreeCtrl->GetSelectedItemID(GetParent(hTreeView)));
if (Order == -1)
return NULL;
return (Order <= TREECTRL_ROOTORDEROFFS) ? (CBaseTreeItem*)&TreeCtrl->RootItems[ROOT_ORDER_TO_INDEX(Order)] : (CBaseTreeItem*)&TreeCtrl->Value[Order];
}
示例3: DefWindowProc
static LRESULT CALLBACK MsgTreeSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
CMsgTree *dat = CWndUserData(GetParent(hWnd)).GetMsgTree();
switch (Msg) {
case UM_MSGTREE_UPDATE: // returns TRUE if updated
{
bool Modified = dat->MsgTreePage.GetModified();
TCString WndTitle;
if (Modified) {
WndTitle.GetBuffer(256);
HWND hCurWnd = hWnd;
do {
hCurWnd = GetParent(hCurWnd);
} while (hCurWnd && !GetWindowText(hCurWnd, WndTitle, 256));
WndTitle.ReleaseBuffer();
}
if (!Modified || MessageBox(GetParent(hWnd), TCString(TranslateT("You've made changes to multiple message trees at a time.\r\nDo you want to leave changes in \"")) + WndTitle + TranslateT("\" dialog?\r\nPress Yes to leave changes in this dialog, or No to discard its changes and save changes of the other message tree instead."), WndTitle + _T(" - ") + TranslateT("New Away System"), MB_ICONQUESTION | MB_YESNO) == IDNO) {
COptItem_TreeCtrl *TreeCtrl = dat->GetTreeCtrl();
TCString OldTitle, OldMsg, NewTitle, NewMsg;
int OldOrder = TreeCtrl->IDToOrder(TreeCtrl->GetSelectedItemID(GetParent(hWnd)));
if (OldOrder != -1) {
CBaseTreeItem* ItemOld = (OldOrder <= TREECTRL_ROOTORDEROFFS) ? (CBaseTreeItem*)&TreeCtrl->RootItems[ROOT_ORDER_TO_INDEX(OldOrder)] : (CBaseTreeItem*)&TreeCtrl->Value[OldOrder];
OldTitle = ItemOld->Title;
if (!(ItemOld->Flags & TIF_ROOTITEM))
OldMsg = ((CTreeItem*)ItemOld)->User_Str1;
}
dat->UpdateLock++;
dat->MsgTreePage.DBToMemToPage();
dat->UpdateLock--;
NMMSGTREE nm = { 0 };
int Order = TreeCtrl->IDToOrder(TreeCtrl->GetSelectedItemID(GetParent(hWnd)));
if (Order != -1) {
nm.ItemNew = (Order <= TREECTRL_ROOTORDEROFFS) ? (CBaseTreeItem*)&TreeCtrl->RootItems[ROOT_ORDER_TO_INDEX(Order)] : (CBaseTreeItem*)&TreeCtrl->Value[Order];
NewTitle = nm.ItemNew->Title;
if (!(nm.ItemNew->Flags & TIF_ROOTITEM))
NewMsg = ((CTreeItem*)nm.ItemNew)->User_Str1;
}
if (OldTitle.IsEmpty())
OldTitle = _T(""); // to be sure that NULL will be equal to "" in the latter comparisons
if (OldMsg.IsEmpty())
OldMsg = _T("");
if (NewTitle.IsEmpty())
NewTitle = _T("");
if (NewMsg.IsEmpty())
NewMsg = _T("");
if (OldTitle != (const TCHAR*)NewTitle || OldMsg != (const TCHAR*)NewMsg) {
// probably it's better to leave nm.ItemOld = NULL, to prevent accidental rewriting of it with old data from an edit control etc.
nm.hdr.code = MTN_SELCHANGED;
nm.hdr.hwndFrom = hWnd;
nm.hdr.idFrom = GetDlgCtrlID(hWnd);
SendMessage(GetParent(hWnd), WM_NOTIFY, 0, (LPARAM)&nm);
}
return true;
}
}
return false;
case WM_KEYDOWN:
switch (wParam) {
case VK_DELETE:
dat->DeleteSelectedItem();
break;
case VK_INSERT:
dat->AddMessage();
break;
}
break;
case WM_RBUTTONDOWN:
SetFocus(hWnd);
{
TVHITTESTINFO hitTest;
hitTest.pt.x = (short)LOWORD(lParam);
hitTest.pt.y = (short)HIWORD(lParam);
TreeView_HitTest(hWnd, &hitTest);
if (hitTest.hItem && hitTest.flags & TVHT_ONITEM)
TreeView_SelectItem(hWnd, hitTest.hItem);
return DefWindowProc(hWnd, Msg, wParam, lParam);
}
break;
case WM_CONTEXTMENU:
{
TVHITTESTINFO ht;
ht.pt.x = GET_X_LPARAM(lParam);
ht.pt.y = GET_Y_LPARAM(lParam);
TVITEM tvi = { 0 };
if (ht.pt.x == -1 && ht.pt.y == -1) { // use selected item
if (tvi.hItem = TreeView_GetSelection(hWnd)) {
TreeView_EnsureVisible(hWnd, tvi.hItem);
RECT rc;
TreeView_GetItemRect(hWnd, tvi.hItem, &rc, true);
ht.pt.x = rc.left;
ht.pt.y = rc.bottom;
}
}
else {
ScreenToClient(hWnd, &ht.pt);
//.........这里部分代码省略.........