From 9238c4e3aa9df5d0726cf3a03e632bc3d3969711 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 2 Jul 2015 13:15:30 +0000 Subject: two new flags of TMO_MenuItem: - CMIF_SYSTEM: filters a menu item out of options' editor; - CMIF_UNMOVABLE: denies attempts to change the item's position; - CMIF_SYSTEM applied to frames' menu; - CMIF_UNMOVABLE applied to Jabber protocol menu items; git-svn-id: http://svn.miranda-ng.org/main/trunk@14468 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- include/m_genmenu.h | 28 ++++---- plugins/Clist_modern/src/CLUIFrames/cluiframes.cpp | 12 ++-- plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp | 14 ++-- protocols/JabberG/src/jabber_menu.cpp | 14 ++-- protocols/JabberG/src/jabber_privacy.cpp | 6 +- protocols/JabberG/src/jabber_xstatus.cpp | 2 +- src/mir_app/res/resource.rc | 2 +- src/mir_app/src/clistmenus.cpp | 3 +- src/mir_app/src/framesmenu.cpp | 4 +- src/mir_app/src/genmenuopt.cpp | 74 +++++++++++++++------- 10 files changed, 91 insertions(+), 68 deletions(-) diff --git a/include/m_genmenu.h b/include/m_genmenu.h index 3e9b93fbc7..d9388ad8bd 100644 --- a/include/m_genmenu.h +++ b/include/m_genmenu.h @@ -17,23 +17,25 @@ #define MO_PROTO (-3) #define MO_STATUS (-4) -#define CMIF_GRAYED 1 -#define CMIF_CHECKED 2 -#define CMIF_HIDDEN 4 //only works on contact menus -#define CMIF_NOTOFFLINE 8 //item won't appear for contacts that are offline -#define CMIF_NOTONLINE 16 // " online -#define CMIF_NOTONLIST 32 //item won't appear on standard contacts -#define CMIF_NOTOFFLIST 64 //item won't appear on contacts that have the 'NotOnList' setting - -#define CMIF_UNICODE 512 //will return TCHAR* instead of char* +#define CMIF_GRAYED 0x0001 +#define CMIF_CHECKED 0x0002 +#define CMIF_HIDDEN 0x0004 // only works on contact menus +#define CMIF_NOTOFFLINE 0x0008 // item won't appear for contacts that are offline +#define CMIF_NOTONLINE 0x0010 // " online +#define CMIF_NOTONLIST 0x0020 // item won't appear on standard contacts +#define CMIF_NOTOFFLIST 0x0040 // item won't appear on contacts that have the 'NotOnList' setting +#define CMIF_UNMOVABLE 0x0080 // item's position cannot be changed +#define CMIF_SYSTEM 0x0100 // item's presence & position cannot be changed + +#define CMIF_UNICODE 0x0200 // will use wchar_t* instead of char* #if defined(_UNICODE) -#define CMIF_TCHAR CMIF_UNICODE //will return TCHAR* instead of char* +#define CMIF_TCHAR CMIF_UNICODE #else -#define CMIF_TCHAR 0 //will return char*, as usual +#define CMIF_TCHAR 0 #endif -#define CMIF_KEEPUNTRANSLATED 1024 // don't translate a menu item -#define CMIF_DEFAULT 4096 // this menu item is the default one +#define CMIF_KEEPUNTRANSLATED 0x0400 // don't translate a menu item +#define CMIF_DEFAULT 0x1000 // this menu item is the default one struct TMO_MenuItem { diff --git a/plugins/Clist_modern/src/CLUIFrames/cluiframes.cpp b/plugins/Clist_modern/src/CLUIFrames/cluiframes.cpp index 23f7be034e..000c96ad02 100644 --- a/plugins/Clist_modern/src/CLUIFrames/cluiframes.cpp +++ b/plugins/Clist_modern/src/CLUIFrames/cluiframes.cpp @@ -771,7 +771,7 @@ static HMENU CLUIFramesCreateMenuForFrame(int frameid, HGENMENU root, int popupp mi.root = root; mi.position = popuppos++; mi.name.a = LPGEN("&Visible"); - mi.flags = CMIF_CHECKED; + mi.flags = CMIF_SYSTEM | CMIF_CHECKED; mi.pszService = MS_CLIST_FRAMES_SHFRAME; fmh.MIVisible = addFrameMenuItem(&mi, frameid, bMain); @@ -795,13 +795,13 @@ static HMENU CLUIFramesCreateMenuForFrame(int frameid, HGENMENU root, int popupp // floating mi.position = popuppos++; mi.name.a = LPGEN("&Floating mode"); - mi.flags = 0; + mi.flags = CMIF_SYSTEM; mi.pszService = "Set_Floating"; fmh.MIFloating = addFrameMenuItem(&mi, frameid, bMain); mi.position = popuppos++; mi.name.a = LPGEN("&Border"); - mi.flags = CMIF_CHECKED; + mi.flags = CMIF_SYSTEM | CMIF_CHECKED; mi.pszService = MS_CLIST_FRAMES_SETUNBORDER; fmh.MIBorder = addFrameMenuItem(&mi, frameid, bMain); @@ -810,7 +810,7 @@ static HMENU CLUIFramesCreateMenuForFrame(int frameid, HGENMENU root, int popupp // alignment root mi.position = popuppos++; mi.name.a = LPGEN("&Align"); - mi.flags = 0; + mi.flags = CMIF_SYSTEM; mi.pszService = NULL; fmh.MIAlignRoot = addFrameMenuItem(&mi, frameid, bMain); @@ -1498,7 +1498,7 @@ static int CLUIFramesLoadMainMenu() int separator = 3000200000; for (int i = 0; i < g_nFramesCount; i++) { mi.hIcolibItem = g_pfwFrames[i].TitleBar.hicon; - mi.flags = CMIF_TCHAR; + mi.flags = CMIF_SYSTEM | CMIF_TCHAR; mi.position = separator++; mi.name.t = g_pfwFrames[i].TitleBar.tbname ? g_pfwFrames[i].TitleBar.tbname : g_pfwFrames[i].name; mi.pszService = 0; @@ -1512,7 +1512,7 @@ static int CLUIFramesLoadMainMenu() // create "show all frames" menu mi.hIcolibItem = NULL; - mi.flags = 0; + mi.flags = CMIF_SYSTEM; mi.position = separator++; mi.name.a = LPGEN("Show all frames"); mi.pszService = MS_CLIST_FRAMES_SHOWALLFRAMES; diff --git a/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp b/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp index 7d8c2a83dc..84c4390de9 100644 --- a/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp +++ b/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp @@ -587,7 +587,7 @@ HMENU CLUIFramesCreateMenuForFrame(int frameid, HGENMENU root, int popuppos, boo mi.root = root; mi.position = popuppos++; mi.name.a = LPGEN("&FrameTitle"); - mi.flags = CMIF_GRAYED; + mi.flags = CMIF_SYSTEM | CMIF_GRAYED; fmh.MITitle = addFrameMenuItem(&mi, frameid, bMain); popuppos += 100000; @@ -595,13 +595,12 @@ HMENU CLUIFramesCreateMenuForFrame(int frameid, HGENMENU root, int popuppos, boo mi.hIcolibItem = NULL; mi.position = popuppos++; mi.name.a = LPGEN("&Visible"); - mi.flags = CMIF_CHECKED; + mi.flags = CMIF_SYSTEM | CMIF_CHECKED; mi.pszService = MS_CLIST_FRAMES_SHFRAME; fmh.MIVisible = addFrameMenuItem(&mi, frameid, bMain); mi.position = popuppos++; mi.name.a = LPGEN("&Show title bar"); - mi.flags = CMIF_CHECKED; mi.pszService = MS_CLIST_FRAMES_SHFRAMETITLEBAR; fmh.MITBVisible = addFrameMenuItem(&mi, frameid, bMain); @@ -609,20 +608,18 @@ HMENU CLUIFramesCreateMenuForFrame(int frameid, HGENMENU root, int popuppos, boo mi.position = popuppos++; mi.name.a = LPGEN("&Locked"); - mi.flags = CMIF_CHECKED; mi.pszService = MS_CLIST_FRAMES_ULFRAME; fmh.MILock = addFrameMenuItem(&mi, frameid, bMain); mi.position = popuppos++; mi.name.a = LPGEN("&Collapsed"); - mi.flags = CMIF_CHECKED; mi.pszService = MS_CLIST_FRAMES_UCOLLFRAME; fmh.MIColl = addFrameMenuItem(&mi, frameid, bMain); // floating mi.position = popuppos++; mi.name.a = LPGEN("&Floating mode"); - mi.flags = 0; + mi.flags = CMIF_SYSTEM; mi.pszService = "Set_Floating"; fmh.MIFloating = addFrameMenuItem(&mi, frameid, bMain); @@ -630,7 +627,7 @@ HMENU CLUIFramesCreateMenuForFrame(int frameid, HGENMENU root, int popuppos, boo mi.position = popuppos++; mi.name.a = LPGEN("&Border"); - mi.flags = CMIF_CHECKED; + mi.flags = CMIF_SYSTEM | CMIF_CHECKED; mi.pszService = MS_CLIST_FRAMES_SETUNBORDER; fmh.MIBorder = addFrameMenuItem(&mi, frameid, bMain); @@ -638,7 +635,6 @@ HMENU CLUIFramesCreateMenuForFrame(int frameid, HGENMENU root, int popuppos, boo mi.position = popuppos++; mi.name.a = LPGEN("&Skinned frame"); - mi.flags = CMIF_CHECKED; mi.pszService = MS_CLIST_FRAMES_SETSKINNED; fmh.MISkinned = addFrameMenuItem(&mi, frameid, bMain); @@ -648,7 +644,7 @@ HMENU CLUIFramesCreateMenuForFrame(int frameid, HGENMENU root, int popuppos, boo mi.root = root; mi.position = popuppos++; mi.name.a = LPGEN("&Align"); - mi.flags = 0; + mi.flags = CMIF_SYSTEM; mi.pszService = NULL; fmh.MIAlignRoot = addFrameMenuItem(&mi, frameid, bMain); diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp index e241a5200c..ba19e2ef1e 100644 --- a/protocols/JabberG/src/jabber_menu.cpp +++ b/protocols/JabberG/src/jabber_menu.cpp @@ -200,6 +200,7 @@ void g_MenuInit(void) // Contact menu initialization CMenuItem mi; + mi.flags = CMIF_UNMOVABLE; // "Request authorization" mi.name.a = LPGEN("Request authorization"); @@ -434,17 +435,15 @@ int CJabberProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM) if (i < item->arResources.getCount()) { pResourceStatus r(item->arResources[i]); - int flags = 0; HICON hIcon = (HICON)INVALID_HANDLE_VALUE; - if (item->resourceMode == RSMODE_MANUAL && item->m_pManualResource == r) - flags |= CMIF_CHECKED; + Menu_SetChecked(m_phMenuResourceItems[i], item->resourceMode == RSMODE_MANUAL && item->m_pManualResource == r); if (ServiceExists(MS_FP_GETCLIENTICONT)) { FormatMirVer(r, szTmp); hIcon = Finger_GetClientIcon(szTmp, 0); } szTmp.Format(_T("%s [%s, %d]"), r->m_tszResourceName, pcli->pfnGetStatusModeDescription(r->m_iStatus, 0), r->m_iPriority); - Menu_ModifyItem(m_phMenuResourceItems[i], szTmp, hIcon, flags); + Menu_ModifyItem(m_phMenuResourceItems[i], szTmp, hIcon); DestroyIcon(hIcon); } else Menu_ShowItem(m_phMenuResourceItems[i], FALSE); @@ -581,6 +580,7 @@ void CJabberProto::MenuInit() { CMenuItem mi; mi.root = m_hMenuRoot = Menu_GetProtocolRoot(this); + mi.flags = CMIF_UNMOVABLE; // "Bookmarks..." mi.pszService = "/Bookmarks"; @@ -679,7 +679,7 @@ void CJabberProto::MenuInit() mi.position = 200006; mi.root = m_hMenuRoot; mi.name.a = LPGEN("Resource priority"); - mi.flags = CMIF_HIDDEN; + mi.flags = CMIF_UNMOVABLE | CMIF_HIDDEN; m_hMenuPriorityRoot = Menu_AddProtoMenuItem(&mi); TCHAR szName[128]; @@ -687,7 +687,7 @@ void CJabberProto::MenuInit() mi.pszService = srvFce; mi.name.t = szName; mi.position = 2000040000; - mi.flags = CMIF_TCHAR | CMIF_KEEPUNTRANSLATED; + mi.flags = CMIF_UNMOVABLE | CMIF_TCHAR | CMIF_KEEPUNTRANSLATED; mi.root = m_hMenuPriorityRoot; mir_snprintf(srvFce, _countof(srvFce), "/menuSetPriority/%d", 0); @@ -767,7 +767,7 @@ void CJabberProto::GlobalMenuInit() // Account chooser menu CMenuItem mi; - mi.flags = CMIF_TCHAR | CMIF_KEEPUNTRANSLATED; + mi.flags = CMIF_UNMOVABLE | CMIF_TCHAR | CMIF_KEEPUNTRANSLATED; mi.position = iChooserMenuPos++; mi.name.t = m_tszUserName; m_hChooseMenuItem = Menu_AddItem(hChooserMenu, &mi, this); diff --git a/protocols/JabberG/src/jabber_privacy.cpp b/protocols/JabberG/src/jabber_privacy.cpp index f70aa8741e..5264a5b250 100644 --- a/protocols/JabberG/src/jabber_privacy.cpp +++ b/protocols/JabberG/src/jabber_privacy.cpp @@ -2093,7 +2093,7 @@ void CJabberProto::BuildPrivacyMenu() CMenuItem mi; mi.position = 200005; mi.hIcolibItem = GetIconHandle(IDI_AGENTS); - mi.flags = CMIF_HIDDEN; + mi.flags = CMIF_UNMOVABLE | CMIF_HIDDEN; mi.name.a = LPGEN("Privacy Lists"); mi.root = m_hMenuRoot; m_hPrivacyMenuRoot = Menu_AddProtoMenuItem(&mi); @@ -2101,7 +2101,7 @@ void CJabberProto::BuildPrivacyMenu() mi.pszService = "/PrivacyLists"; CreateProtoService(mi.pszService, &CJabberProto::OnMenuHandlePrivacyLists); mi.position = 3000040000; - mi.flags = CMIF_TCHAR; + mi.flags = CMIF_UNMOVABLE | CMIF_TCHAR; mi.hIcolibItem = GetIconHandle(IDI_PRIVACY_LISTS); mi.name.t = LPGENT("List Editor..."); mi.root = m_hPrivacyMenuRoot; @@ -2122,7 +2122,7 @@ void CJabberProto::BuildPrivacyListsMenu(bool bDeleteOld) CMenuItem mi; mi.position = 2000040000; - mi.flags = CMIF_TCHAR; + mi.flags = CMIF_UNMOVABLE | CMIF_TCHAR; mi.root = m_hPrivacyMenuRoot; mi.pszService = srvFce; diff --git a/protocols/JabberG/src/jabber_xstatus.cpp b/protocols/JabberG/src/jabber_xstatus.cpp index ddde385b99..5e532fb7c5 100644 --- a/protocols/JabberG/src/jabber_xstatus.cpp +++ b/protocols/JabberG/src/jabber_xstatus.cpp @@ -469,7 +469,7 @@ void CPepGuiService::RebuildMenu() mi.root = hJabberRoot; mi.pszService = szService; mi.position = 200010; - mi.flags = CMIF_TCHAR | CMIF_HIDDEN; + mi.flags = CMIF_UNMOVABLE | CMIF_TCHAR | CMIF_HIDDEN; mi.hIcolibItem = m_hIcolibItem; mi.name.t = m_szText ? m_szText : _T(""); m_hMenuItem = Menu_AddProtoMenuItem(&mi, m_proto->m_szModuleName); diff --git a/src/mir_app/res/resource.rc b/src/mir_app/res/resource.rc index 7b86ad92ea..ef4583b099 100644 --- a/src/mir_app/res/resource.rc +++ b/src/mir_app/res/resource.rc @@ -487,7 +487,7 @@ BEGIN GROUPBOX "Menu objects",IDC_STATIC,5,2,140,94 LISTBOX IDC_MENUOBJECTS,11,13,128,79,WS_VSCROLL | WS_TABSTOP GROUPBOX "Menu items",IDC_STATIC,149,2,161,248 - CONTROL "Tree1",IDC_MENUITEMS,"SysTreeView32",TVS_SHOWSELALWAYS | WS_DISABLED | WS_BORDER | WS_HSCROLL | WS_TABSTOP,156,13,148,212 + CONTROL "Tree1",IDC_MENUITEMS,"SysTreeView32",TVS_SHOWSELALWAYS | TVS_HASLINES | WS_DISABLED | WS_BORDER | WS_HSCROLL | WS_TABSTOP,156,13,148,212 GROUPBOX "Protocol menus",IDC_STATIC,5,100,140,37 CONTROL "Move to the main menu",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON,11,111,128,8 CONTROL "Move to the status bar",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON,11,123,130,8 diff --git a/src/mir_app/src/clistmenus.cpp b/src/mir_app/src/clistmenus.cpp index fe6499c42f..596a5e3116 100644 --- a/src/mir_app/src/clistmenus.cpp +++ b/src/mir_app/src/clistmenus.cpp @@ -1106,7 +1106,7 @@ void InitCustomMenus(void) CreateServiceFunction("StatusMenuExecService", StatusMenuExecService); CreateServiceFunction("StatusMenuCheckService", StatusMenuCheckService); - //free services + // free services CreateServiceFunction("CLISTMENUS/FreeOwnerDataMainMenu", FreeOwnerDataMainMenu); CreateServiceFunction("CLISTMENUS/FreeOwnerDataContactMenu", FreeOwnerDataContactMenu); CreateServiceFunction("CLISTMENUS/FreeOwnerDataStatusMenu", FreeOwnerDataStatusMenu); @@ -1165,7 +1165,6 @@ void InitCustomMenus(void) HookEvent(ME_HOTKEYS_CHANGED, sttRebuildHotkeys); // add exit command to menu - CMenuItem mi; mi.position = 0x7fffffff; mi.pszService = "CloseAction"; diff --git a/src/mir_app/src/framesmenu.cpp b/src/mir_app/src/framesmenu.cpp index 98f7da0cdd..4d904620df 100644 --- a/src/mir_app/src/framesmenu.cpp +++ b/src/mir_app/src/framesmenu.cpp @@ -34,7 +34,7 @@ static HANDLE hPreBuildFrameMenuEvent; // also used in checkservice struct FrameMenuExecParam { - ptrA szServiceName; + ptrA szServiceName; }; INT_PTR FreeOwnerDataFrameMenu(WPARAM, LPARAM lParam) @@ -65,7 +65,7 @@ INT_PTR FrameMenuExecService(WPARAM wParam, LPARAM lParam) return 0; } -//true - ok,false ignore +// true - ok,false ignore INT_PTR FrameMenuCheckService(WPARAM wParam, LPARAM) { TCheckProcParam *pcpp = (TCheckProcParam*)wParam; diff --git a/src/mir_app/src/genmenuopt.cpp b/src/mir_app/src/genmenuopt.cpp index cd2653227f..6e57e67f9d 100644 --- a/src/mir_app/src/genmenuopt.cpp +++ b/src/mir_app/src/genmenuopt.cpp @@ -141,29 +141,23 @@ class CGenMenuOptionsPage : public CDlgBase BuildTree(MenuObjectID, true); } - bool BuildTree(int MenuObjectId, bool bReread) + void BuildTreeInternal(const char *pszModule, bool bReread, HGENMENU pFirst, HTREEITEM hRoot) { - FreeTreeData(); - - TIntMenuObject *pmo = GetMenuObjbyId(MenuObjectId); - if (pmo == NULL || pmo->m_items.first == NULL) - return false; - - char menuItemName[256], MenuNameItems[256]; - mir_snprintf(MenuNameItems, _countof(MenuNameItems), "%s_Items", pmo->pszName); - LIST arItems(10, SortMenuItems); - for (TMO_IntMenuItem *p = pmo->m_items.first; p != NULL; p = p->next) { - if (p->mi.root != (HGENMENU)-1 && p->mi.root != NULL) + for (TMO_IntMenuItem *p = pFirst; p != NULL; p = p->next) { + // filter out items whose presence & position might not be changed + if (p->mi.flags & CMIF_SYSTEM) continue; + char menuItemName[256]; + GetMenuItemName(p, menuItemName, _countof(menuItemName)); + MenuItemOptData *PD = new MenuItemOptData(); - GetMenuItemName(p, menuItemName, sizeof(menuItemName)); char buf[256]; mir_snprintf(buf, "%s_name", menuItemName); - ptrT tszName(db_get_tsa(NULL, MenuNameItems, buf)); + ptrT tszName(db_get_tsa(NULL, pszModule, buf)); if (tszName != 0) PD->name = tszName.detach(); else @@ -173,11 +167,11 @@ class CGenMenuOptionsPage : public CDlgBase PD->defname = mir_tstrdup(GetMenuItemText(p)); mir_snprintf(buf, "%s_visible", menuItemName); - PD->bShow = db_get_b(NULL, MenuNameItems, buf, 1) != 0; + PD->bShow = db_get_b(NULL, pszModule, buf, 1) != 0; if (bReread) { mir_snprintf(buf, "%s_pos", menuItemName); - PD->pos = db_get_dw(NULL, MenuNameItems, buf, 1); + PD->pos = db_get_dw(NULL, pszModule, buf, 1); } else PD->pos = (PD->pimi) ? PD->pimi->originalPosition : 0; @@ -189,17 +183,13 @@ class CGenMenuOptionsPage : public CDlgBase arItems.insert(PD); } - bRebuild = true; - m_menuItems.SendMsg(WM_SETREDRAW, FALSE, 0); - m_menuItems.DeleteAllItems(); - int lastpos = 0; bool bIsFirst = TRUE; TVINSERTSTRUCT tvis; - tvis.hParent = NULL; + tvis.hParent = hRoot; tvis.hInsertAfter = TVI_LAST; - tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE; + tvis.item.mask = TVIF_PARAM | TVIF_CHILDREN | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE; for (int i = 0; i < arItems.getCount(); i++) { MenuItemOptData *PD = arItems[i]; @@ -212,21 +202,47 @@ class CGenMenuOptionsPage : public CDlgBase tvis.item.lParam = (LPARAM)sep; tvis.item.pszText = sep->name; tvis.item.iImage = tvis.item.iSelectedImage = 1; + tvis.item.cChildren = 0; m_menuItems.InsertItem(&tvis); } tvis.item.lParam = (LPARAM)PD; tvis.item.pszText = PD->name; tvis.item.iImage = tvis.item.iSelectedImage = PD->bShow; + tvis.item.cChildren = PD->pimi->submenu.first != NULL; HTREEITEM hti = m_menuItems.InsertItem(&tvis); if (bIsFirst) { - m_menuItems.SelectItem(hti); + if (hRoot == NULL) + m_menuItems.SelectItem(hti); bIsFirst = false; } + if (PD->pimi->submenu.first != NULL) { + BuildTreeInternal(pszModule, bReread, PD->pimi->submenu.first, hti); + m_menuItems.Expand(hti, TVE_EXPAND); + } + lastpos = PD->pos; } + } + + bool BuildTree(int MenuObjectId, bool bReread) + { + FreeTreeData(); + + TIntMenuObject *pmo = GetMenuObjbyId(MenuObjectId); + if (pmo == NULL || pmo->m_items.first == NULL) + return false; + + char MenuNameItems[256]; + mir_snprintf(MenuNameItems, _countof(MenuNameItems), "%s_Items", pmo->pszName); + + bRebuild = true; + m_menuItems.SendMsg(WM_SETREDRAW, FALSE, 0); + m_menuItems.DeleteAllItems(); + + BuildTreeInternal(MenuNameItems, bReread, pmo->m_items.first, NULL); m_menuItems.SendMsg(WM_SETREDRAW, TRUE, 0); bRebuild = false; @@ -280,6 +296,7 @@ public: m_menuItems.SetFlags(MTREE_CHECKBOX | MTREE_DND | MTREE_MULTISELECT); m_menuItems.OnSelChanged = Callback(this, &CGenMenuOptionsPage::onMenuItemChanged); + m_menuItems.OnBeginDrag = Callback(this, &CGenMenuOptionsPage::onMenuItemDrag); m_customName.SetSilent(); m_service.SetSilent(); @@ -289,7 +306,7 @@ public: virtual void OnInitDialog() { iInitMenuValue = db_get_b(NULL, "CList", "MoveProtoMenus", TRUE); - + HIMAGELIST himlCheckBoxes = ImageList_Create(g_iIconSX, g_iIconSY, ILC_COLOR32 | ILC_MASK, 2, 2); ImageList_AddIcon_IconLibLoaded(himlCheckBoxes, SKINICON_OTHER_NOTICK); ImageList_AddIcon_IconLibLoaded(himlCheckBoxes, SKINICON_OTHER_TICK); @@ -459,6 +476,15 @@ public: m_btnSet.Enable(true); m_customName.Enable(true); } + + void onMenuItemDrag(CCtrlTreeView::TEventInfo *evt) + { + MenuItemOptData *p = (MenuItemOptData*)evt->nmtv->itemNew.lParam; + if (p->pimi == NULL) + evt->nmhdr->code = 0; // reject an attempt to move a separator + else if (p->pimi->mi.flags & CMIF_UNMOVABLE) + evt->nmhdr->code = 0; // reject an attempt to change item's position + } }; int GenMenuOptInit(WPARAM wParam, LPARAM) -- cgit v1.2.3