当前位置: 首页>>代码示例>>C++>>正文


C++ COptItem_TreeCtrl::SetModified方法代码示例

本文整理汇总了C++中COptItem_TreeCtrl::SetModified方法的典型用法代码示例。如果您正苦于以下问题:C++ COptItem_TreeCtrl::SetModified方法的具体用法?C++ COptItem_TreeCtrl::SetModified怎么用?C++ COptItem_TreeCtrl::SetModified使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在COptItem_TreeCtrl的用法示例。


在下文中一共展示了COptItem_TreeCtrl::SetModified方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: UpdateItem

void CMsgTree::UpdateItem(int ID) // updates item title, and expanded/collapsed state for groups
{
    COptItem_TreeCtrl *TreeCtrl = GetTreeCtrl();
    int Order = TreeCtrl->IDToOrder(ID);
    if (Order != -1) {
        CBaseTreeItem* TreeItem = (Order <= TREECTRL_ROOTORDEROFFS) ? (CBaseTreeItem*)&TreeCtrl->RootItems[ROOT_ORDER_TO_INDEX(Order)] : (CBaseTreeItem*)&TreeCtrl->Value[Order];
        TCString NewTitle;
        TVITEM tvi;
        tvi.mask = TVIF_HANDLE | TVIF_TEXT;
        tvi.hItem = TreeItem->hItem;
        tvi.pszText = NewTitle.GetBuffer(TREEITEMTITLE_MAXLEN);
        tvi.cchTextMax = TREEITEMTITLE_MAXLEN;
        TreeView_GetItem(hTreeView, &tvi);
        if (TreeItem->Title != (const TCHAR*)tvi.pszText) {
            TreeCtrl->SetModified(true);
            NMMSGTREE nm = { 0 };
            nm.ItemNew = TreeItem;
            nm.hdr.code = MTN_ITEMRENAMED;
            nm.hdr.hwndFrom = hTreeView;
            nm.hdr.idFrom = GetDlgCtrlID(hTreeView);
            SendMessage(GetParent(hTreeView), WM_NOTIFY, 0, (LPARAM)&nm);
        }
        tvi.mask = TVIF_HANDLE | TVIF_TEXT;
        tvi.pszText = TreeItem->Title;
        TreeView_SetItem(hTreeView, &tvi);
        TreeView_Expand(hTreeView, tvi.hItem, (TreeItem->Flags & TIF_EXPANDED) ? TVE_EXPAND : TVE_COLLAPSE);
    }
}
开发者ID:kmdtukl,项目名称:miranda-ng,代码行数:28,代码来源:MsgTree.cpp

示例2: SetMsgFormat

void CProtoSettings::SetMsgFormat(int Flags, TCString Message)
{
    if (Flags & (SMF_TEMPORARY | SMF_PERSONAL) && g_AutoreplyOptPage.GetDBValueCopy(IDC_REPLYDLG_RESETCOUNTERWHENSAMEICON) && GetMsgFormat(Flags & (SMF_TEMPORARY | SMF_PERSONAL)) != (const TCHAR*)Message)
        ResetSettingsOnStatusChange(szProto);

    if (Flags & SMF_TEMPORARY) {
        _ASSERT(!Status || Status == g_ProtoStates[szProto].Status);
        g_ProtoStates[szProto].TempMsg = (szProto || Message != NULL) ? Message : CProtoSettings(NULL, Status).GetMsgFormat(GMF_LASTORDEFAULT);
    }

    if (Flags & SMF_PERSONAL) { // set a "personal" message for a protocol. also it's used to set global status message (hContact = NULL).
        // if Message == NULL, then we'll use the "default" message - i.e. it's either the global message for szProto != NULL (we delete the per-proto DB setting), or it's just a default message for a given status for szProto == NULL.
        g_ProtoStates[szProto].TempMsg.Unset();
        CString DBSetting(ProtoStatusToDBSetting(DB_STATUSMSG, IDC_MOREOPTDLG_PERSTATUSPROTOMSGS));
        if (Message != NULL)
            db_set_ts(NULL, MOD_NAME, DBSetting, Message);
        else {
            if (!szProto)
                db_set_ts(NULL, MOD_NAME, DBSetting, CProtoSettings(NULL, Status).GetMsgFormat(GMF_LASTORDEFAULT)); // global message can't be NULL; we can use an empty string instead if it's really necessary
            else
                db_unset(NULL, MOD_NAME, DBSetting);
        }
    }

    if (Flags & SMF_LAST) {
        COptPage MsgTreeData(g_MsgTreePage);
        COptItem_TreeCtrl *TreeCtrl = (COptItem_TreeCtrl*)MsgTreeData.Find(IDV_MSGTREE);
        TreeCtrl->DBToMem(CString(MOD_NAME));
        int RecentGroupID = GetRecentGroupID(Status);
        if (RecentGroupID == -1) { // we didn't find the group, it also means that we're using per status messages; so we need to create it
            TreeCtrl->Value.AddElem(CTreeItem(Status ? pcli->pfnGetStatusModeDescription(Status, 0) : MSGTREE_RECENT_OTHERGROUP, g_Messages_RecentRootID, RecentGroupID = TreeCtrl->GenerateID(), TIF_GROUP));
            TreeCtrl->SetModified(true);
        }
        int i;
        // try to find an identical message in the same group (to prevent saving multiple identical messages), 
        // or at least if we'll find an identical message somewhere else, then we'll use its title for our new message
        TCString Title(_T(""));
        for (i = 0; i < TreeCtrl->Value.GetSize(); i++) {
            if (!(TreeCtrl->Value[i].Flags & TIF_GROUP) && TreeCtrl->Value[i].User_Str1 == (const TCHAR*)Message) {
                if (TreeCtrl->Value[i].ParentID == RecentGroupID) { // found it in the same group
                    int GroupOrder = TreeCtrl->IDToOrder(RecentGroupID);
                    TreeCtrl->Value.MoveElem(i, (GroupOrder >= 0) ? (GroupOrder + 1) : 0); // now move it to the top of recent messages list
                    TreeCtrl->SetModified(true);
                    break; // no reason to search for anything else
                }
                if (Title.IsEmpty()) // it's not in the same group, but at least we'll use its title
                    Title = TreeCtrl->Value[i].Title;
            }
        }
        if (i == TreeCtrl->Value.GetSize()) { // we didn't find an identical message in the same group, so we'll add our new message here
            if (Title.IsEmpty()) { // didn't find a title for our message either
                if (Message.GetLen() > MRM_MAX_GENERATED_TITLE_LEN)
                    Title = Message.Left(MRM_MAX_GENERATED_TITLE_LEN - 3) + _T("...");
                else
                    Title = Message;

                TCHAR *p = Title.GetBuffer();
                while (*p) { // remove "garbage"
                    if (!(p = _tcspbrk(p, _T("\r\n\t"))))
                        break;

                    *p++ = ' ';
                }
                Title.ReleaseBuffer();
            }
            int GroupOrder = TreeCtrl->IDToOrder(RecentGroupID);
            TreeCtrl->Value.InsertElem(CTreeItem(Title, RecentGroupID, TreeCtrl->GenerateID(), 0, Message), (GroupOrder >= 0) ? (GroupOrder + 1) : 0);
            TreeCtrl->SetModified(true);
        }

        // now clean up here
        int MRMNum = 0;
        int MaxMRMNum = g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_RECENTMSGSCOUNT);
        for (i = 0; i < TreeCtrl->Value.GetSize(); i++) {
            if (TreeCtrl->Value[i].ParentID == RecentGroupID) { // found a child of our group
                if (TreeCtrl->Value[i].Flags & TIF_GROUP || ++MRMNum > MaxMRMNum) { // what groups are doing here?! :))
                    TreeCtrl->Value.RemoveElem(i);
                    TreeCtrl->SetModified(true);
                    i--;
                }
            }
        }

        // if we're saving recent messages per status, then remove any messages that were left at the recent messages' root
        if (g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_PERSTATUSMRM)) {
            for (i = 0; i < TreeCtrl->Value.GetSize(); i++) {
                if (TreeCtrl->Value[i].ParentID == g_Messages_RecentRootID) {
                    if (!(TreeCtrl->Value[i].Flags & TIF_GROUP)) {
                        TreeCtrl->Value.RemoveElem(i);
                        TreeCtrl->SetModified(true);
                        i--;
                    }
                }
            }
        }
        TreeCtrl->MemToDB(CString(MOD_NAME));
    }
}
开发者ID:0xmono,项目名称:miranda-ng,代码行数:98,代码来源:Properties.cpp

示例3: CallWindowProc

static LRESULT CALLBACK ParentSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
    CMsgTree *dat = CWndUserData(hWnd).GetMsgTree();
    switch (Msg) {
    case WM_NOTIFY:
        if (((LPNMHDR)lParam)->hwndFrom == dat->hTreeView) {
            switch (((LPNMHDR)lParam)->code) {
            case TVN_BEGINDRAG:
                {
                    LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam;
                    NMMSGTREE nm = { 0 };
                    COptItem_TreeCtrl *TreeCtrl = dat->GetTreeCtrl();
                    int Order = TreeCtrl->hItemToOrder(pnmtv->itemNew.hItem);
                    _ASSERT(Order != -1);
                    if (Order != -1) {
                        nm.ItemOld = (Order <= TREECTRL_ROOTORDEROFFS) ? (CBaseTreeItem*)&TreeCtrl->RootItems[ROOT_ORDER_TO_INDEX(Order)] : (CBaseTreeItem*)&TreeCtrl->Value[Order];
                        nm.hdr.code = MTN_BEGINDRAG;
                        nm.hdr.hwndFrom = dat->hTreeView;
                        nm.hdr.idFrom = GetDlgCtrlID(dat->hTreeView);
                        if (!SendMessage(hWnd, WM_NOTIFY, 0, (LPARAM)&nm)) {
                            SetCapture(hWnd);
                            dat->hPrevDropTarget = dat->hDragItem = pnmtv->itemNew.hItem;
                            SetFocus(dat->hTreeView);
                            TreeView_SelectItem(dat->hTreeView, dat->hDragItem);
                        }
                    }
                }
                break;

            case TVN_SELCHANGED:
                if (dat->UpdateLock)
                    return 0;
                else {
                    LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam;
                    NMMSGTREE nm = { 0 };
                    COptItem_TreeCtrl *TreeCtrl = dat->GetTreeCtrl();
                    if (pnmtv->itemOld.hItem) {
                        int Order = TreeCtrl->IDToOrder(pnmtv->itemOld.lParam);
                        if (Order != -1) {
                            nm.ItemOld = (Order <= TREECTRL_ROOTORDEROFFS) ? (CBaseTreeItem*)&TreeCtrl->RootItems[ROOT_ORDER_TO_INDEX(Order)] : (CBaseTreeItem*)&TreeCtrl->Value[Order];
                        }
                    }
                    if (pnmtv->itemNew.hItem) {
                        int Order = TreeCtrl->IDToOrder(pnmtv->itemNew.lParam);
                        if (Order != -1) {
                            nm.ItemNew = (Order <= TREECTRL_ROOTORDEROFFS) ? (CBaseTreeItem*)&TreeCtrl->RootItems[ROOT_ORDER_TO_INDEX(Order)] : (CBaseTreeItem*)&TreeCtrl->Value[Order];
                        }
                    }
                    nm.hdr.code = MTN_SELCHANGED;
                    nm.hdr.hwndFrom = dat->hTreeView;
                    nm.hdr.idFrom = GetDlgCtrlID(dat->hTreeView);
                    SendMessage(hWnd, WM_NOTIFY, 0, (LPARAM)&nm);
                }
                break;

            case TVN_BEGINLABELEDIT:
                if (dat->GetTreeCtrl()->IDToOrder(((LPNMTVDISPINFO)lParam)->item.lParam) < 0)
                    return true; // cancel editing

                g_OrigEditProc = (WNDPROC)SetWindowLongPtr(TreeView_GetEditControl(dat->hTreeView), GWLP_WNDPROC, (LONG_PTR)EditSubclassProc);
                break;

            case TVN_ENDLABELEDIT:
                {
                    LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO)lParam;
                    if (ptvdi->item.pszText) {
                        COptItem_TreeCtrl *TreeCtrl = dat->GetTreeCtrl();
                        int Order = TreeCtrl->IDToOrder(ptvdi->item.lParam);
                        if (Order >= 0) {
                            TreeCtrl->Value[Order].Title = ptvdi->item.pszText;
                            TreeCtrl->SetModified(true);
                            NMMSGTREE nm = { 0 };
                            nm.ItemNew = &TreeCtrl->Value[Order];
                            nm.hdr.code = MTN_ITEMRENAMED;
                            nm.hdr.hwndFrom = dat->hTreeView;
                            nm.hdr.idFrom = GetDlgCtrlID(dat->hTreeView);
                            SendMessage(GetParent(dat->hTreeView), WM_NOTIFY, 0, (LPARAM)&nm);
                            return true; // commit new text
                        }
                    }
                }
                break;

            case NM_CLICK:
            case NM_RCLICK:
                {
                    TVHITTESTINFO hitTest;
                    hitTest.pt.x = (short)LOWORD(GetMessagePos());
                    hitTest.pt.y = (short)HIWORD(GetMessagePos());
                    ScreenToClient(dat->hTreeView, &hitTest.pt);
                    TreeView_HitTest(dat->hTreeView, &hitTest);
                    if (hitTest.hItem) {
                        if (TreeView_GetSelection(dat->hTreeView) == hitTest.hItem) // make sure TVN_SELCHANGED notification is sent always, even if previous selected item was the same as new
                            TreeView_SelectItem(dat->hTreeView, NULL);
                        TreeView_SelectItem(dat->hTreeView, hitTest.hItem);
                    }
                }
                break;

            case NM_CUSTOMDRAW:
//.........这里部分代码省略.........
开发者ID:kmdtukl,项目名称:miranda-ng,代码行数:101,代码来源:MsgTree.cpp


注:本文中的COptItem_TreeCtrl::SetModified方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。