void WdeInitToolMenu( HINSTANCE inst, HMENU menu ) { int i; for( i = 0; WdeMenuBitmaps[i].bmp != NULL; i++ ) { WdeMenuBitmaps[i].hbmp = LoadBitmap( inst, WdeMenuBitmaps[i].bmp ); GetMenuString( menu, WdeMenuBitmaps[i].id, WdeMenuBitmaps[i].string, 255, MF_BYCOMMAND ); if( WdeMenuBitmaps[i].hbmp != NULL ) { ModifyMenu( menu, WdeMenuBitmaps[i].id, MF_BYCOMMAND | MF_OWNERDRAW, WdeMenuBitmaps[i].id, (LPCSTR)&WdeMenuBitmaps[i] ); } } }
/* * menu_destory - メニューの破棄 */ void menu_destory(HMENU hMenu) { HMENU hSubMenu; int cnt, i; cnt = GetMenuItemCount(hMenu); for (i = 0; i < cnt; i++) { if ((hSubMenu = GetSubMenu(hMenu, i)) != NULL) { menu_destory(hSubMenu); ModifyMenu(hMenu, i, MF_BYPOSITION, 0, NULL); } } DestroyMenu(hMenu); }
void Menu::updateGroup( HMENU hmenu, int& index, ItemPtr item, const MENUITEMINFO& info ) { HMENU sub = info.hSubMenu; if( !info.dwTypeData || buildMenuText( item ) != (LPCTSTR)info.dwTypeData ) ModifyMenu( hmenu, index, MF_BYPOSITION | MF_STRING, item->commandID(), buildMenuText( item ).c_str() ); if( sub == NULL ) { MENUITEMINFO info = { sizeof( info ), MIIM_SUBMENU }; info.hSubMenu = ( sub = CreateMenu() ); SetMenuItemInfo( hmenu, index, TRUE, &info ); } EnableMenuItem( hmenu, index, MF_BYPOSITION | ( item->update() ? MF_ENABLED : MF_GRAYED ) ); changed( sub, item ); }
void fileOpen(){ if(!openFile()){ MessageBox(hwnd, "Opening file error!", "Error", MB_OK | MB_ICONERROR); return; } createNotifs(); if(hEdit != NULL){ ModifyMenu(hMenu, ID_FILE_SAVE, MF_BYCOMMAND | MF_ENABLED, ID_FILE_SAVE, "&Save\tCtrl + S"); ModifyMenu(hMenu, ID_FILE_CLOSE, MF_BYCOMMAND | MF_ENABLED, ID_FILE_CLOSE, "&Close\tCtrl + C"); HDC hdc; hdc = GetWindowDC(hwnd); int i, counter = 0; for(i = strlen(openedFileName) - 1; i > 0; i--){ if(openedFileName[i] == '\\'){ fileName[counter] = '\0'; break; } fileName[counter] = openedFileName[i]; counter++; } TextOut(hdc, 160, 70, strrev(fileName), strlen(fileName)); ReleaseDC(hwnd, hdc); } }
void wxMenu::SetTitle(const wxString& label) { bool hasNoTitle = m_title.empty(); m_title = label; HMENU hMenu = GetHmenu(); if ( hasNoTitle ) { if ( !label.empty() ) { if ( !::InsertMenu(hMenu, 0u, MF_BYPOSITION | MF_STRING, (UINT_PTR)idMenuTitle, m_title.t_str()) || !::InsertMenu(hMenu, 1u, MF_BYPOSITION, (unsigned)-1, NULL) ) { wxLogLastError(wxT("InsertMenu")); } } } else { if ( label.empty() ) { // remove the title and the separator after it if ( !RemoveMenu(hMenu, 0, MF_BYPOSITION) || !RemoveMenu(hMenu, 0, MF_BYPOSITION) ) { wxLogLastError(wxT("RemoveMenu")); } } else { // modify the title if ( !ModifyMenu(hMenu, 0u, MF_BYPOSITION | MF_STRING, (UINT_PTR)idMenuTitle, m_title.t_str()) ) { wxLogLastError(wxT("ModifyMenu")); } } } // put the title string in bold face if ( !m_title.empty() ) { SetDefaultMenuItem(GetHmenu(), (UINT)idMenuTitle); } }
static void mh_updateLabel (menu* m, wchar_t* label, int flags, int key) { BOOL alloced = FALSE; if (!label) { alloced=TRUE; label = mh_getLabel(m); } if (flags==-1 && key==-1) findAccelerator(m->command, &flags, &key) ; if (flags!=0 && key!=0) { const wchar_t* z = mh_buildLabel(label, flags, key); if (alloced) free(label); label = z; } int flg2 = MF_BYCOMMAND | (m->sub? MF_POPUP : MF_STRING); ModifyMenu(m->parent, m->command, flg2, m->command, label); if (alloced || (flags!=0 && key!=0)) free(label); }
static void prepare_context_menu(HMENU hmenu) { khm_int32 cmd; wchar_t caption[128]; cmd = get_default_notifier_action(); if (cmd == KHUI_ACTION_NEW_CRED) LoadString(hResModule, IDS_ACT_NEW, caption, ARRAYLENGTH(caption)); else LoadString(hResModule, IDS_ACT_OPEN, caption, ARRAYLENGTH(caption)); ModifyMenu(hmenu, ID_DEFAULT, MF_STRING|MF_BYCOMMAND, ID_DEFAULT, caption); SetMenuDefaultItem(hmenu, ID_DEFAULT, FALSE); }
void consolewin_info::update_menu() { disasmbasewin_info::update_menu(); if (m_devices_menu != nullptr) { // create the image menu uint32_t cnt = 0; for (device_image_interface &img : image_interface_iterator(machine().root_device())) { HMENU const devicesubmenu = CreatePopupMenu(); UINT_PTR const new_item = ID_DEVICE_OPTIONS + (cnt * DEVOPTION_MAX); UINT flags_for_exists = MF_ENABLED | MF_STRING; if (!img.exists()) flags_for_exists |= MF_GRAYED; UINT flags_for_writing = flags_for_exists; if (img.is_readonly()) flags_for_writing |= MF_GRAYED; AppendMenu(devicesubmenu, MF_STRING, new_item + DEVOPTION_OPEN, TEXT("Mount...")); if (img.is_creatable()) AppendMenu(devicesubmenu, MF_STRING, new_item + DEVOPTION_CREATE, TEXT("Create...")); AppendMenu(devicesubmenu, flags_for_exists, new_item + DEVOPTION_CLOSE, TEXT("Unmount")); if (img.device().type() == CASSETTE) { cassette_state const state = (cassette_state)(img.exists() ? (downcast<cassette_image_device *>(&img.device())->get_state() & CASSETTE_MASK_UISTATE) : CASSETTE_STOPPED); AppendMenu(devicesubmenu, MF_SEPARATOR, 0, nullptr); AppendMenu(devicesubmenu, flags_for_exists | ((state == CASSETTE_STOPPED) ? MF_CHECKED : 0), new_item + DEVOPTION_CASSETTE_STOPPAUSE, TEXT("Pause/Stop")); AppendMenu(devicesubmenu, flags_for_exists | ((state == CASSETTE_PLAY) ? MF_CHECKED : 0), new_item + DEVOPTION_CASSETTE_PLAY, TEXT("Play")); AppendMenu(devicesubmenu, flags_for_writing | ((state == CASSETTE_RECORD) ? MF_CHECKED : 0), new_item + DEVOPTION_CASSETTE_RECORD, TEXT("Record")); AppendMenu(devicesubmenu, flags_for_exists, new_item + DEVOPTION_CASSETTE_REWIND, TEXT("Rewind")); AppendMenu(devicesubmenu, flags_for_exists, new_item + DEVOPTION_CASSETTE_FASTFORWARD, TEXT("Fast Forward")); } osd::text::tstring tc_buf = osd::text::to_tstring(string_format("%s :%s", img.device().name(), img.exists() ? img.filename() : "[empty slot]")); ModifyMenu(m_devices_menu, cnt, MF_BYPOSITION | MF_POPUP, (UINT_PTR)devicesubmenu, tc_buf.c_str()); cnt++; } } }
void wintitle(void) { char buf[256]; if (strlen(gli_story_name)) sprintf(buf, "%s - %s", gli_story_name, gli_program_name); else sprintf(buf, "%s", gli_program_name); SetWindowTextA(hwndframe, buf); if (strcmp(gli_program_name, "Unknown")) sprintf(buf, "About Gargoyle / %s...", gli_program_name); else strcpy(buf, "About Gargoyle..."); ModifyMenu(GetSystemMenu(hwndframe, 0), ID_ABOUT, MF_BYCOMMAND | MF_STRING, ID_ABOUT, buf); DrawMenuBar(hwndframe); }
void disasmbasewin_info::update_menu() { editwin_info::update_menu(); disasmview_info *const dasmview = downcast<disasmview_info *>(m_views[0].get()); HMENU const menu = GetMenu(window()); bool const disasm_cursor_visible = dasmview->cursor_visible(); if (disasm_cursor_visible) { offs_t const address = dasmview->selected_address(); device_debug *const debug = dasmview->source_device()->debug(); // first find an existing breakpoint at this address device_debug::breakpoint *bp = debug->breakpoint_first(); while ((bp != NULL) && (bp->address() != address)) bp = bp->next(); if (bp == NULL) { ModifyMenu(menu, ID_TOGGLE_BREAKPOINT, MF_BYCOMMAND, ID_TOGGLE_BREAKPOINT, TEXT("Set breakpoint at cursor\tF9")); ModifyMenu(menu, ID_DISABLE_BREAKPOINT, MF_BYCOMMAND, ID_DISABLE_BREAKPOINT, TEXT("Disable breakpoint at cursor\tShift+F9")); } else { ModifyMenu(menu, ID_TOGGLE_BREAKPOINT, MF_BYCOMMAND, ID_TOGGLE_BREAKPOINT, TEXT("Clear breakpoint at cursor\tF9")); if (bp->enabled()) ModifyMenu(menu, ID_DISABLE_BREAKPOINT, MF_BYCOMMAND, ID_DISABLE_BREAKPOINT, TEXT("Disable breakpoint at cursor\tShift+F9")); else ModifyMenu(menu, ID_DISABLE_BREAKPOINT, MF_BYCOMMAND, ID_DISABLE_BREAKPOINT, TEXT("Enable breakpoint at cursor\tShift+F9")); } bool const available = (bp != NULL) && (!is_main_console() || dasmview->source_is_visible_cpu()); EnableMenuItem(menu, ID_DISABLE_BREAKPOINT, MF_BYCOMMAND | (available ? MF_ENABLED : MF_GRAYED)); } else { ModifyMenu(menu, ID_TOGGLE_BREAKPOINT, MF_BYCOMMAND, ID_TOGGLE_BREAKPOINT, TEXT("Toggle breakpoint at cursor\tF9")); ModifyMenu(menu, ID_DISABLE_BREAKPOINT, MF_BYCOMMAND, ID_DISABLE_BREAKPOINT, TEXT("Disable breakpoint at cursor\tShift+F9")); EnableMenuItem(menu, ID_DISABLE_BREAKPOINT, MF_BYCOMMAND | MF_GRAYED); } EnableMenuItem(menu, ID_TOGGLE_BREAKPOINT, MF_BYCOMMAND | (disasm_cursor_visible ? MF_ENABLED : MF_GRAYED)); EnableMenuItem(menu, ID_RUN_TO_CURSOR, MF_BYCOMMAND | (disasm_cursor_visible ? MF_ENABLED : MF_GRAYED)); disasm_right_column const rightcol = dasmview->right_column(); CheckMenuItem(menu, ID_SHOW_RAW, MF_BYCOMMAND | (rightcol == DASM_RIGHTCOL_RAW ? MF_CHECKED : MF_UNCHECKED)); CheckMenuItem(menu, ID_SHOW_ENCRYPTED, MF_BYCOMMAND | (rightcol == DASM_RIGHTCOL_ENCRYPTED ? MF_CHECKED : MF_UNCHECKED)); CheckMenuItem(menu, ID_SHOW_COMMENTS, MF_BYCOMMAND | (rightcol == DASM_RIGHTCOL_COMMENTS ? MF_CHECKED : MF_UNCHECKED)); }
void ShowMruMenu() { HMENU hMenu = GetSubMenu(GetMenu(hThisWindow), 0); int n, i; //first count the MRU list for (n = 0; MruBuffer[n] != NULL; n++) ; // no code required //add enough entries for (i = MenusShown; i < n; i++) AppendMenu(hMenu, MF_STRING, ID_MRU+i, MruBuffer[i]); MenusShown = (n == 0 ? 1 : n); //then change them for (i = 0; i < n; i++) ModifyMenu(hMenu, ID_MRU+i, MF_BYCOMMAND, ID_MRU+i, MruBuffer[i]); }
//Open the logging file and update the menus void StartLogging() { int result = MessageBoxEx(NULL, "Note: this will log all CPU info to a text file\ named log.txt in the same directory as the program. This file will become\ large very quickly. Are you sure you what to do this?", "Project 8", MB_OKCANCEL | MB_ICONWARNING, 0); if(result == IDCANCEL) return; Project8::logging = true; HMENU menu = GetMenu(window.getWindowHwnd()); ModifyMenu(menu, 9005 /*ID_LOG*/, MF_BYCOMMAND | MF_CHECKED, 9005 /*ID_LOG*/, "Enable Logging"); SetMenu(window.getWindowHwnd(), menu); LogFile = CreateFile("log.txt", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); }
void OSMDIChildWnd::detachMDI() { if (detached) return; detached = 1; if(m_parent) { OSMDIClientWnd * realparent = m_parent->getMDIClient(); if ( realparent ) realparent->unregisterRootWndChild(this); m_parent->updateMDIControlButtons(isMaximized()); } m_oldparent = m_parent; setMDIParent(NULL); reparent(NULL); #ifdef DETACHABLE HMENU sysm = GetSystemMenu(getOsWindowHandle(), FALSE); UINT currentID = MDICHILD_SYSMENU_DETACH; ModifyMenu(sysm,MDICHILD_SYSMENU_DETACH,MF_STRING,(UINT_PTR)currentID,"Attach to main window"); #endif //if (getMenu()) SetMenu(gethWnd(), getMenu()); fucko }
void PopupMenuEx( HWND hWnd, ITEMID idControl, ITEMID idMenu, ITEMID idMenuChange ) /***********************************************************************/ { HMENU hMenu, hPopup; HWND hTool; RECT Rect; STRING szMenuChange; if ( !(hMenu = LoadMenu( hInstAstral, MAKEINTRESOURCE(idMenu) )) ) return; if ( !(hPopup = GetSubMenu( hMenu, 0 )) ) { DestroyMenu( hMenu ); return; } if ( idMenuChange ) { if ( GetDlgItemText( hWnd, idMenuChange, szMenuChange, sizeof(STRING) )) ModifyMenu( hPopup, IDC_FILENAME, MF_BYCOMMAND | MF_STRING, IDC_FILENAME, szMenuChange ); else { EnableMenuItem( hPopup, IDC_DELETEEXT, MF_BYCOMMAND|MF_GRAYED ); EnableMenuItem( hPopup, IDC_RENAMEEXT, MF_BYCOMMAND|MF_GRAYED ); } } /* Get the handle to the control we'll popup beside */ if ( !(hTool = GetDlgItem( hWnd, idControl ) ) ) { DestroyMenu( hMenu ); return; } /* Get screen coordinates of the tool */ GetWindowRect( hTool, &Rect ); /* Draw and track the "floating" popup */ TrackPopupMenu( hPopup, 0, Rect.right, Rect.top, 0, hWnd, NULL ); DestroyMenu( hMenu ); }
void DOSBoxMenu::item::refresh_item(DOSBoxMenu &menu) { (void)menu;//POSSIBLY UNUSED #if DOSBOXMENU_TYPE == DOSBOXMENU_HMENU /* Windows menu handle */ if (menu.winMenu != NULL && status.in_use && status.changed) { HMENU phandle = NULL; if (parent_id != unassigned_item_handle) phandle = menu.get_item(parent_id).winMenu; else phandle = menu.winMenu; if (phandle != NULL) { if (type == separator_type_id) { /* none */ } else if (type == vseparator_type_id) { /* none */ } else if (type == submenu_type_id) { /* TODO: Can't change by ID, have to change by position */ } else if (type == item_type_id) { unsigned int attr = MF_STRING; attr |= (status.checked) ? MF_CHECKED : MF_UNCHECKED; attr |= (status.enabled) ? MF_ENABLED : (MF_DISABLED | MF_GRAYED); ModifyMenu(phandle, (uintptr_t)(master_id + winMenuMinimumID), attr | MF_BYCOMMAND, (uintptr_t)(master_id + winMenuMinimumID), winConstructMenuText().c_str()); } } } status.changed = false; #endif #if DOSBOXMENU_TYPE == DOSBOXMENU_NSMENU /* Mac OS X menu handle */ if (nsMenuItem != NULL) sdl_hax_nsMenuItemUpdateFromItem(nsMenuItem, *this); #endif }
void APIENTRY glutChangeToSubMenu(int num, const char *label, int menu) { GLUTmenu *popupmenu; GLUTmenuItem *item; int i; if (__glutMappedMenu) { menuModificationError(); } i = __glutCurrentMenu->num; item = __glutCurrentMenu->list; while (item) { if (i == num) { if (!item->isTrigger) { /* If changing a menu entry to as submenu trigger, we need to account for submenus. */ item->menu->submenus++; item->win = (HWND) CreatePopupMenu(); } free(item->label); item->label = strdup(label); if (!item->label) __glutFatalError("out of memory"); item->isTrigger = TRUE; item->len = (int) strlen(label); item->value = menu - 1; item->unique = uniqueMenuHandler++; popupmenu = __glutGetMenuByNum(menu); if (popupmenu) item->win = popupmenu->win; ModifyMenu((HMENU) __glutCurrentMenu->win, (UINT) i - 1, MF_BYPOSITION | MF_POPUP, (UINT) item->win, label); return; } i--; item = item->next; } __glutWarning("Current menu has no %d item.", num); }
void UpdateMenu() { int i, x, y, full_w, full_h; char tmp[20]; if (pvar->ResizeMenu == NULL) return; GetMonitorSizeByChar(&full_w, &full_h); for (i=0; i < pvar->MenuItems; i++) { x = pvar->ResizeList[i][0]; y = pvar->ResizeList[i][1]; if (x == -1 || y == -1) { if (x == -1) x = full_w; if (y == -1) y = full_h; mkMenuEntry(tmp, sizeof(tmp), (x==-1)?full_w:x, (y==-1)?full_h:y, i); ModifyMenu(pvar->ResizeMenu, i, MF_BYPOSITION, ID_MENUID_BASE+i, tmp); } } }
void APIENTRY glutChangeToMenuEntry(int num, const char *label, int value) { GLUTmenuItem *item; int i; if (__glutMappedMenu) { menuModificationError(); } i = __glutCurrentMenu->num; item = __glutCurrentMenu->list; while (item) { if (i == num) { if (item->isTrigger) { /* If changing a submenu trigger to a menu entry, we need to account for submenus. */ item->menu->submenus--; /* Nuke the Win32 menu. */ DestroyMenu((HMENU) item->win); } free(item->label); item->label = strdup(label); if (!item->label) __glutFatalError("out of memory"); item->isTrigger = FALSE; item->len = (int) strlen(label); item->value = value; item->unique = uniqueMenuHandler++; ModifyMenu((HMENU) __glutCurrentMenu->win, (UINT) i - 1, MF_BYPOSITION | MFT_STRING, item->unique, label); return; } i--; item = item->next; } __glutWarning("Current menu has no %d item.", num); }
/* using MIIM_STRING doesn't work for win9x/winnt4, so trying an older way */ void uikeyboard_menu_shortcuts(HMENU menu) { int i; int stringsize; LPTSTR buf, newbuf; for (i = 0; idmlist[i].cmd > 0; i++) { if (menuitemmodifier[idmlist[i].cmd] != NULL) { stringsize = GetMenuString(menu, idmlist[i].cmd, NULL, 0, MF_BYCOMMAND); if (stringsize != 0) { stringsize++; buf = lib_malloc(stringsize); if (GetMenuString(menu, idmlist[i].cmd, buf, stringsize, MF_BYCOMMAND)) { newbuf = util_concat(buf, menuitemmodifier[idmlist[i].cmd], NULL); ModifyMenu(menu, idmlist[i].cmd, MF_BYCOMMAND | MF_STRING, idmlist[i].cmd, newbuf); lib_free(newbuf); } lib_free(buf); } } } }
void UpdateCommands() { static GlobalUIState lastGlobalUIState = UISTATE_PAUSEMENU; static CoreState lastCoreState = CORE_ERROR; if (lastGlobalUIState == globalUIState && lastCoreState == coreState) return; lastCoreState = coreState; lastGlobalUIState = globalUIState; HMENU menu = GetMenu(GetHWND()); const char* pauseMenuText = (Core_IsStepping() || globalUIState != UISTATE_INGAME) ? "Run\tF8" : "Pause\tF8"; ModifyMenu(menu, ID_TOGGLE_PAUSE, MF_BYCOMMAND | MF_STRING, ID_TOGGLE_PAUSE, pauseMenuText); UINT ingameEnable = globalUIState == UISTATE_INGAME ? MF_ENABLED : MF_GRAYED; EnableMenuItem(menu, ID_TOGGLE_PAUSE, ingameEnable); EnableMenuItem(menu, ID_EMULATION_STOP, ingameEnable); EnableMenuItem(menu, ID_EMULATION_RESET, ingameEnable); UINT menuEnable = globalUIState == UISTATE_MENU ? MF_ENABLED : MF_GRAYED; EnableMenuItem(menu, ID_FILE_SAVESTATEFILE, !menuEnable); EnableMenuItem(menu, ID_FILE_LOADSTATEFILE, !menuEnable); EnableMenuItem(menu, ID_FILE_QUICKSAVESTATE, !menuEnable); EnableMenuItem(menu, ID_FILE_QUICKLOADSTATE, !menuEnable); EnableMenuItem(menu, ID_CPU_DYNAREC, menuEnable); EnableMenuItem(menu, ID_CPU_INTERPRETER, menuEnable); EnableMenuItem(menu, ID_CPU_MULTITHREADED, menuEnable); EnableMenuItem(menu, ID_IO_MULTITHREADED, menuEnable); EnableMenuItem(menu, ID_TOGGLE_PAUSE, !menuEnable); EnableMenuItem(menu, ID_EMULATION_STOP, !menuEnable); EnableMenuItem(menu, ID_EMULATION_RESET, !menuEnable); EnableMenuItem(menu, ID_DEBUG_LOG, !g_Config.bEnableLogging); EnableMenuItem(menu, ID_EMULATION_RENDER_MODE_OGL, menuEnable); EnableMenuItem(menu, ID_EMULATION_RENDER_MODE_SOFT, menuEnable); EnableMenuItem(menu, ID_EMULATION_ATRAC3_SOUND, !Atrac3plus_Decoder::IsInstalled()); }
static VOID ShowHideMousePointer(HANDLE ConOutHandle, BOOLEAN ShowPtr) { WCHAR szMenuString[255] = L""; if (ShowPtr) { /* Be sure the cursor will be shown */ while (ShowConsoleCursor(ConOutHandle, TRUE) < 0) ; } else { /* Be sure the cursor will be hidden */ while (ShowConsoleCursor(ConOutHandle, FALSE) >= 0) ; } if (LoadStringW(GetModuleHandle(NULL), (!ShowPtr ? IDS_SHOW_MOUSE : IDS_HIDE_MOUSE), szMenuString, sizeof(szMenuString) / sizeof(szMenuString[0])) > 0) { ModifyMenu(hConsoleMenu, ID_SHOWHIDE_MOUSE, MF_BYCOMMAND, ID_SHOWHIDE_MOUSE, szMenuString); } }
/* * MenuRenumberSpells: Reset spell menu ids when a spell is removed. */ void MenuRenumberSpells(void) { int num, i, j; char name[MAXRSCSTRING]; HMENU submenu; if (spell_menu == NULL) return; for (i=0; i < num_schools; i++) { submenu = submenus[i]; if (submenu) { num = GetMenuItemCount(submenu); for (j=0; j < num; j++) { GetMenuString(submenu, j, name, MAXRSCSTRING, MF_BYPOSITION); ModifyMenu(submenu, j, MF_STRING | MF_BYPOSITION, ID_SPELL + j + i * MAX_SPELLS_PER_SCHOOL, name); } } } }
void CAcceleratorManager::UpdateMenu(HMENU menu) { int count = GetMenuItemCount(menu); OSVERSIONINFO info = {0}; info.dwOSVersionInfoSize = sizeof(info); GetVersionEx(&info); if (info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { MENUITEMINFO info = {0}; info.cbSize = sizeof(info) - sizeof(HBITMAP); info.fMask = MIIM_ID | MIIM_SUBMENU; for (int i = 0; i < count; i++) { GetMenuItemInfo(menu, i, TRUE, &info); if (info.hSubMenu != NULL) { UpdateMenu(info.hSubMenu); } else { if (info.wID != (UINT)-1) { char ss[128]; MENUITEMINFO info2 = {0}; info2.cbSize = sizeof(info2) - sizeof(HBITMAP); // FIXME: why? info2.fMask = MIIM_STRING; info2.dwTypeData = ss; info2.cch = 128; GetMenuItemInfo(menu, i, MF_BYPOSITION, &info2); CString str(ss); int index = str.Find('\t'); if (index != -1) str = str.Left(index); WORD command = info.wID; CCmdAccelOb *o; if (m_mapAccelTable.Lookup(command, o)) { if (o->m_Accels.GetCount()) { POSITION pos = o->m_Accels.GetHeadPosition(); CAccelsOb *accel = o->m_Accels.GetNext(pos); CString s; accel->GetString(s); str += "\t"; str += s; } } if (str != ss) ModifyMenu(menu, i, MF_BYPOSITION | MF_STRING, info.wID, str); } } } } else { MENUITEMINFO info = {0}; info.cbSize = sizeof(info); info.fMask = MIIM_ID | MIIM_SUBMENU; for (int i = 0; i < count; i++) { GetMenuItemInfo(menu, i, TRUE, &info); if (info.hSubMenu != NULL) { UpdateMenu(info.hSubMenu); } else { if (info.wID != (WORD)-1) { wchar_t ss[128]; wchar_t str[512]; MENUITEMINFOW info2 = {0}; info2.cbSize = sizeof(info2); info2.fMask = MIIM_STRING; info2.dwTypeData = ss; info2.cch = 128; GetMenuItemInfoW(menu, i, MF_BYPOSITION, &info2); wcscpy(str, ss); wchar_t *p = wcschr(str, '\t'); if (p) *p = 0; CCmdAccelOb *o; WORD command = info.wID; if (m_mapAccelTable.Lookup(command, o)) { if (o->m_Accels.GetCount()) { POSITION pos = o->m_Accels.GetHeadPosition(); CAccelsOb *accel = o->m_Accels.GetNext(pos); CString s; accel->GetString(s); wchar_t temp[128]; temp[0] = '\t'; temp[1] = 0; wcscat(str, temp); p = temp; for (const char *sp = s; *sp; sp++) *p++ = *sp; *p = 0; wcscat(str, temp); } } if (wcscmp(str, ss)) ModifyMenuW(menu, i, MF_BYPOSITION | MF_STRING, info.wID, str); } } } } }
void RenameMenu(HMENU hMenu, UINT cmdId, UINT textId) { UINT state = GetMenuState(hMenu, cmdId, MF_BYCOMMAND); ModifyMenu(hMenu, cmdId, MF_BYCOMMAND|state, cmdId, Locale::GetInstance().GetString(textId)); }
UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, TCHAR* pszUID, TCHAR* pszWordText) { HMENU hSubMenu = 0; *hMenu = GetSubMenu(g_hMenu, iIndex); TranslateMenu(*hMenu); GCMENUITEMS gcmi = { 0 }; gcmi.pszID = si->ptszID; gcmi.pszModule = si->pszModule; gcmi.pszUID = pszUID; if (iIndex == 1) { int i = GetRichTextLength(GetDlgItem(hwndDlg, IDC_LOG)); EnableMenuItem(*hMenu, ID_CLEARLOG, MF_ENABLED); EnableMenuItem(*hMenu, ID_COPYALL, MF_ENABLED); ModifyMenu(*hMenu, 4, MF_GRAYED | MF_BYPOSITION, 4, NULL); if (!i) { EnableMenuItem(*hMenu, ID_COPYALL, MF_BYCOMMAND | MF_GRAYED); EnableMenuItem(*hMenu, ID_CLEARLOG, MF_BYCOMMAND | MF_GRAYED); if (pszWordText && pszWordText[0]) ModifyMenu(*hMenu, 4, MF_ENABLED | MF_BYPOSITION, 4, NULL); } if (pszWordText && pszWordText[0]) { TCHAR szMenuText[4096]; mir_sntprintf(szMenuText, _countof(szMenuText), TranslateT("Look up '%s':"), pszWordText); ModifyMenu(*hMenu, 4, MF_STRING | MF_BYPOSITION, 4, szMenuText); } else ModifyMenu(*hMenu, 4, MF_STRING | MF_GRAYED | MF_BYPOSITION, 4, TranslateT("No word to look up")); gcmi.Type = MENU_ON_LOG; } else if (iIndex == 0) { TCHAR szTemp[50]; if (pszWordText) mir_sntprintf(szTemp, TranslateT("&Message %s"), pszWordText); else mir_tstrncpy(szTemp, TranslateT("&Message"), _countof(szTemp) - 1); if (mir_tstrlen(szTemp) > 40) mir_tstrcpy(szTemp + 40, _T("...")); ModifyMenu(*hMenu, ID_MESS, MF_STRING | MF_BYCOMMAND, ID_MESS, szTemp); gcmi.Type = MENU_ON_NICKLIST; } NotifyEventHooks(pci->hBuildMenuEvent, 0, (WPARAM)&gcmi); if (gcmi.nItems > 0) AppendMenu(*hMenu, MF_SEPARATOR, 0, 0); for (int i = 0; i < gcmi.nItems; i++) { TCHAR* ptszText = TranslateTS(gcmi.Item[i].pszDesc); DWORD dwState = gcmi.Item[i].bDisabled ? MF_GRAYED : 0; if (gcmi.Item[i].uType == MENU_NEWPOPUP) { hSubMenu = CreateMenu(); AppendMenu(*hMenu, dwState | MF_POPUP, (UINT_PTR)hSubMenu, ptszText); } else if (gcmi.Item[i].uType == MENU_POPUPHMENU) AppendMenu(hSubMenu == 0 ? *hMenu : hSubMenu, dwState | MF_POPUP, gcmi.Item[i].dwID, ptszText); else if (gcmi.Item[i].uType == MENU_POPUPITEM) AppendMenu(hSubMenu == 0 ? *hMenu : hSubMenu, dwState | MF_STRING, gcmi.Item[i].dwID, ptszText); else if (gcmi.Item[i].uType == MENU_POPUPCHECK) AppendMenu(hSubMenu == 0 ? *hMenu : hSubMenu, dwState | MF_CHECKED | MF_STRING, gcmi.Item[i].dwID, ptszText); else if (gcmi.Item[i].uType == MENU_POPUPSEPARATOR) AppendMenu(hSubMenu == 0 ? *hMenu : hSubMenu, MF_SEPARATOR, 0, ptszText); else if (gcmi.Item[i].uType == MENU_SEPARATOR) AppendMenu(*hMenu, MF_SEPARATOR, 0, ptszText); else if (gcmi.Item[i].uType == MENU_HMENU) AppendMenu(*hMenu, dwState | MF_POPUP, gcmi.Item[i].dwID, ptszText); else if (gcmi.Item[i].uType == MENU_ITEM) AppendMenu(*hMenu, dwState | MF_STRING, gcmi.Item[i].dwID, ptszText); else if (gcmi.Item[i].uType == MENU_CHECK) AppendMenu(*hMenu, dwState | MF_CHECKED | MF_STRING, gcmi.Item[i].dwID, ptszText); } return TrackPopupMenu(*hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL); }
void CTEKWindow::InitMenu(HMENU *Menu) { *Menu = ::LoadMenu(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_TEKMENU)); EditMenu = GetSubMenu(MainMenu,1); FileMenu = GetSubMenu(MainMenu,0); SetupMenu = GetSubMenu(MainMenu,2); HelpMenu = GetSubMenu(MainMenu,4); char uimsg[MAX_UIMSG]; GetMenuString(*Menu, 0, uimsg, sizeof(uimsg), MF_BYPOSITION); get_lang_msg("TEKMENU_FILE", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile); ModifyMenu(*Menu, 0, MF_BYPOSITION, 0, ts.UIMsg); GetMenuString(FileMenu, ID_TEKFILE_PRINT, uimsg, sizeof(uimsg), MF_BYCOMMAND); get_lang_msg("TEKMENU_FILE_PRINT", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile); ModifyMenu(FileMenu, ID_TEKFILE_PRINT, MF_BYCOMMAND, ID_TEKFILE_PRINT, ts.UIMsg); GetMenuString(FileMenu, ID_TEKFILE_EXIT, uimsg, sizeof(uimsg), MF_BYCOMMAND); get_lang_msg("TEKMENU_FILE_EXIT", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile); ModifyMenu(FileMenu, ID_TEKFILE_EXIT, MF_BYCOMMAND, ID_TEKFILE_EXIT, ts.UIMsg); GetMenuString(*Menu, 1, uimsg, sizeof(uimsg), MF_BYPOSITION); get_lang_msg("TEKMENU_EDIT", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile); ModifyMenu(*Menu, 1, MF_BYPOSITION, 1, ts.UIMsg); GetMenuString(EditMenu, ID_TEKEDIT_COPY, uimsg, sizeof(uimsg), MF_BYCOMMAND); get_lang_msg("TEKMENU_EDIT_COPY", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile); ModifyMenu(EditMenu, ID_TEKEDIT_COPY, MF_BYCOMMAND, ID_TEKEDIT_COPY, ts.UIMsg); GetMenuString(EditMenu, ID_TEKEDIT_COPYSCREEN, uimsg, sizeof(uimsg), MF_BYCOMMAND); get_lang_msg("TEKMENU_EDIT_COPYSCREEN", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile); ModifyMenu(EditMenu, ID_TEKEDIT_COPYSCREEN, MF_BYCOMMAND, ID_TEKEDIT_COPYSCREEN, ts.UIMsg); GetMenuString(EditMenu, ID_TEKEDIT_PASTE, uimsg, sizeof(uimsg), MF_BYCOMMAND); get_lang_msg("TEKMENU_EDIT_PASTE", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile); ModifyMenu(EditMenu, ID_TEKEDIT_PASTE, MF_BYCOMMAND, ID_TEKEDIT_PASTE, ts.UIMsg); GetMenuString(EditMenu, ID_TEKEDIT_PASTECR, uimsg, sizeof(uimsg), MF_BYCOMMAND); get_lang_msg("TEKMENU_EDIT_PASTECR", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile); ModifyMenu(EditMenu, ID_TEKEDIT_PASTECR, MF_BYCOMMAND, ID_TEKEDIT_PASTECR, ts.UIMsg); GetMenuString(EditMenu, ID_TEKEDIT_CLEARSCREEN, uimsg, sizeof(uimsg), MF_BYCOMMAND); get_lang_msg("TEKMENU_EDIT_CLSCREEN", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile); ModifyMenu(EditMenu, ID_TEKEDIT_CLEARSCREEN, MF_BYCOMMAND, ID_TEKEDIT_CLEARSCREEN, ts.UIMsg); GetMenuString(*Menu, 2, uimsg, sizeof(uimsg), MF_BYPOSITION); get_lang_msg("TEKMENU_SETUP", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile); ModifyMenu(*Menu, 2, MF_BYPOSITION, 2, ts.UIMsg); GetMenuString(SetupMenu, ID_TEKSETUP_WINDOW, uimsg, sizeof(uimsg), MF_BYCOMMAND); get_lang_msg("TEKMENU_SETUP_WINDOW", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile); ModifyMenu(SetupMenu, ID_TEKSETUP_WINDOW, MF_BYCOMMAND, ID_TEKSETUP_WINDOW, ts.UIMsg); GetMenuString(SetupMenu, ID_TEKSETUP_FONT, uimsg, sizeof(uimsg), MF_BYCOMMAND); get_lang_msg("TEKMENU_SETUP_FONT", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile); ModifyMenu(SetupMenu, ID_TEKSETUP_FONT, MF_BYCOMMAND, ID_TEKSETUP_FONT, ts.UIMsg); GetMenuString(*Menu, ID_TEKVTWIN, uimsg, sizeof(uimsg), MF_BYCOMMAND); get_lang_msg("TEKMENU_VTWIN", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile); ModifyMenu(*Menu, ID_TEKVTWIN, MF_BYCOMMAND, ID_TEKVTWIN, ts.UIMsg); GetMenuString(*Menu, 4, uimsg, sizeof(uimsg), MF_BYPOSITION); get_lang_msg("TEKMENU_HELP", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile); ModifyMenu(*Menu, 4, MF_BYPOSITION, 4, ts.UIMsg); GetMenuString(HelpMenu, ID_TEKHELP_INDEX, uimsg, sizeof(uimsg), MF_BYCOMMAND); get_lang_msg("TEKMENU_HELP_INDEX", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile); ModifyMenu(HelpMenu, ID_TEKHELP_INDEX, MF_BYCOMMAND, ID_TEKHELP_INDEX, ts.UIMsg); GetMenuString(HelpMenu, ID_TEKHELP_ABOUT, uimsg, sizeof(uimsg), MF_BYCOMMAND); get_lang_msg("TEKMENU_HELP_ABOUT", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile); ModifyMenu(HelpMenu, ID_TEKHELP_ABOUT, MF_BYCOMMAND, ID_TEKHELP_ABOUT, ts.UIMsg); if ((ts.MenuFlag & MF_SHOWWINMENU) !=0) { WinMenu = CreatePopupMenu(); get_lang_msg("TEKMENU_WINDOW", ts.UIMsg, sizeof(ts.UIMsg), "&Window", ts.UILanguageFile); ::InsertMenu(*Menu,4,MF_STRING | MF_ENABLED | MF_POPUP | MF_BYPOSITION, (int)WinMenu, ts.UIMsg); } }
HMENU ContextMenu::CreateSkinMenu(Skin* skin, int index, HMENU menu) { static const MenuTemplate s_Menu[] = { MENU_ITEM(IDM_SKIN_OPENSKINSFOLDER, 0), MENU_SEPARATOR(), MENU_SUBMENU(ID_STR_VARIANTS, MENU_SEPARATOR()), MENU_SEPARATOR(), MENU_SUBMENU(ID_STR_SETTINGS, MENU_SUBMENU(ID_STR_POSITION, MENU_SUBMENU(ID_STR_DISPLAYMONITOR, MENU_ITEM(IDM_SKIN_MONITOR_PRIMARY, ID_STR_USEDEFAULTMONITOR), MENU_ITEM(ID_MONITOR_FIRST, ID_STR_VIRTUALSCREEN), MENU_SEPARATOR(), MENU_SEPARATOR(), MENU_ITEM(IDM_SKIN_MONITOR_AUTOSELECT, ID_STR_AUTOSELECTMONITOR)), MENU_SEPARATOR(), MENU_ITEM(IDM_SKIN_VERYTOPMOST, ID_STR_STAYTOPMOST), MENU_ITEM(IDM_SKIN_TOPMOST, ID_STR_TOPMOST), MENU_ITEM(IDM_SKIN_NORMAL, ID_STR_NORMAL), MENU_ITEM(IDM_SKIN_BOTTOM, ID_STR_BOTTOM), MENU_ITEM(IDM_SKIN_ONDESKTOP, ID_STR_ONDESKTOP), MENU_SEPARATOR(), MENU_ITEM(IDM_SKIN_FROMRIGHT, ID_STR_FROMRIGHT), MENU_ITEM(IDM_SKIN_FROMBOTTOM, ID_STR_FROMBOTTOM), MENU_ITEM(IDM_SKIN_XPERCENTAGE, ID_STR_XASPERCENTAGE), MENU_ITEM(IDM_SKIN_YPERCENTAGE, ID_STR_YASPERCENTAGE)), MENU_SUBMENU(ID_STR_TRANSPARENCY, MENU_ITEM(IDM_SKIN_TRANSPARENCY_0, ID_STR_0PERCENT), MENU_ITEM(IDM_SKIN_TRANSPARENCY_10, ID_STR_10PERCENT), MENU_ITEM(IDM_SKIN_TRANSPARENCY_20, ID_STR_20PERCENT), MENU_ITEM(IDM_SKIN_TRANSPARENCY_30, ID_STR_30PERCENT), MENU_ITEM(IDM_SKIN_TRANSPARENCY_40, ID_STR_40PERCENT), MENU_ITEM(IDM_SKIN_TRANSPARENCY_50, ID_STR_50PERCENT), MENU_ITEM(IDM_SKIN_TRANSPARENCY_60, ID_STR_60PERCENT), MENU_ITEM(IDM_SKIN_TRANSPARENCY_70, ID_STR_70PERCENT), MENU_ITEM(IDM_SKIN_TRANSPARENCY_80, ID_STR_80PERCENT), MENU_ITEM(IDM_SKIN_TRANSPARENCY_90, ID_STR_90PERCENT), MENU_ITEM(IDM_SKIN_TRANSPARENCY_100, ID_STR_100PERCENT), MENU_SEPARATOR(), MENU_ITEM(IDM_SKIN_TRANSPARENCY_FADEIN, ID_STR_FADEIN), MENU_ITEM(IDM_SKIN_TRANSPARENCY_FADEOUT, ID_STR_FADEOUT)), MENU_SEPARATOR(), MENU_ITEM(IDM_SKIN_HIDEONMOUSE, ID_STR_HIDEONMOUSEOVER), MENU_ITEM(IDM_SKIN_DRAGGABLE, ID_STR_DRAGGABLE), MENU_ITEM(IDM_SKIN_REMEMBERPOSITION, ID_STR_SAVEPOSITION), MENU_ITEM(IDM_SKIN_SNAPTOEDGES, ID_STR_SNAPTOEDGES), MENU_ITEM(IDM_SKIN_CLICKTHROUGH, ID_STR_CLICKTHROUGH), MENU_ITEM(IDM_SKIN_KEEPONSCREEN, ID_STR_KEEPONSCREEN), MENU_ITEM(IDM_SKIN_USED2D, ID_STR_USED2D), MENU_ITEM(IDM_SKIN_FAVORITE, ID_STR_FAVORITE)), MENU_SEPARATOR(), MENU_ITEM(IDM_SKIN_MANAGESKIN, ID_STR_MANAGESKIN), MENU_ITEM(IDM_SKIN_EDITSKIN, ID_STR_EDITSKIN), MENU_ITEM(IDM_SKIN_REFRESH, ID_STR_REFRESHSKIN), MENU_SEPARATOR(), MENU_ITEM(IDM_CLOSESKIN, ID_STR_UNLOADSKIN) }; HMENU skinMenu = MenuTemplate::CreateMenu(s_Menu, _countof(s_Menu), GetString); if (!skinMenu) return nullptr; // Tick the position HMENU settingsMenu = GetSubMenu(skinMenu, 4); if (settingsMenu) { HMENU posMenu = GetSubMenu(settingsMenu, 0); if (posMenu) { const UINT checkPos = IDM_SKIN_NORMAL - (UINT)skin->GetWindowZPosition(); CheckMenuRadioItem(posMenu, checkPos, checkPos, checkPos, MF_BYCOMMAND); if (skin->GetXFromRight()) CheckMenuItem(posMenu, IDM_SKIN_FROMRIGHT, MF_BYCOMMAND | MF_CHECKED); if (skin->GetYFromBottom()) CheckMenuItem(posMenu, IDM_SKIN_FROMBOTTOM, MF_BYCOMMAND | MF_CHECKED); if (skin->GetXPercentage()) CheckMenuItem(posMenu, IDM_SKIN_XPERCENTAGE, MF_BYCOMMAND | MF_CHECKED); if (skin->GetYPercentage()) CheckMenuItem(posMenu, IDM_SKIN_YPERCENTAGE, MF_BYCOMMAND | MF_CHECKED); HMENU monitorMenu = GetSubMenu(posMenu, 0); if (monitorMenu) { CreateMonitorMenu(monitorMenu, skin); } } // Tick the transparency HMENU alphaMenu = GetSubMenu(settingsMenu, 1); if (alphaMenu) { int alpha = skin->GetAlphaValue(); if (alpha <= 1) // ~100% { CheckMenuRadioItem(alphaMenu, 10, 10, 10, MF_BYPOSITION); } else { UINT checkPos = (UINT)(10 - alpha / 25.5); checkPos = min(9, checkPos); checkPos = max(0, checkPos); CheckMenuRadioItem(alphaMenu, checkPos, checkPos, checkPos, MF_BYPOSITION); } switch (skin->GetWindowHide()) { case HIDEMODE_FADEIN: CheckMenuItem(alphaMenu, IDM_SKIN_TRANSPARENCY_FADEIN, MF_BYCOMMAND | MF_CHECKED); EnableMenuItem(alphaMenu, IDM_SKIN_TRANSPARENCY_FADEOUT, MF_BYCOMMAND | MF_GRAYED); break; case HIDEMODE_FADEOUT: CheckMenuItem(alphaMenu, IDM_SKIN_TRANSPARENCY_FADEOUT, MF_BYCOMMAND | MF_CHECKED); EnableMenuItem(alphaMenu, IDM_SKIN_TRANSPARENCY_FADEIN, MF_BYCOMMAND | MF_GRAYED); break; case HIDEMODE_HIDE: EnableMenuItem(alphaMenu, IDM_SKIN_TRANSPARENCY_FADEIN, MF_BYCOMMAND | MF_GRAYED); EnableMenuItem(alphaMenu, IDM_SKIN_TRANSPARENCY_FADEOUT, MF_BYCOMMAND | MF_GRAYED); break; } } // Tick the settings switch (skin->GetWindowHide()) { case HIDEMODE_HIDE: CheckMenuItem(settingsMenu, IDM_SKIN_HIDEONMOUSE, MF_BYCOMMAND | MF_CHECKED); break; case HIDEMODE_FADEIN: case HIDEMODE_FADEOUT: EnableMenuItem(settingsMenu, IDM_SKIN_HIDEONMOUSE, MF_BYCOMMAND | MF_GRAYED); break; } if (skin->GetSnapEdges()) { CheckMenuItem(settingsMenu, IDM_SKIN_SNAPTOEDGES, MF_BYCOMMAND | MF_CHECKED); } if (skin->GetSavePosition()) { CheckMenuItem(settingsMenu, IDM_SKIN_REMEMBERPOSITION, MF_BYCOMMAND | MF_CHECKED); } if (GetRainmeter().m_DisableDragging) { EnableMenuItem(settingsMenu, IDM_SKIN_DRAGGABLE, MF_BYCOMMAND | MF_GRAYED); } else if (skin->GetWindowDraggable()) { CheckMenuItem(settingsMenu, IDM_SKIN_DRAGGABLE, MF_BYCOMMAND | MF_CHECKED); } if (skin->GetClickThrough()) { CheckMenuItem(settingsMenu, IDM_SKIN_CLICKTHROUGH, MF_BYCOMMAND | MF_CHECKED); } if (skin->GetKeepOnScreen()) { CheckMenuItem(settingsMenu, IDM_SKIN_KEEPONSCREEN, MF_BYCOMMAND | MF_CHECKED); } if (Gfx::CanvasD2D::Initialize()) { if (!Rainmeter::GetInstance().GetUseD2D()) { EnableMenuItem(settingsMenu, IDM_SKIN_USED2D, MF_BYCOMMAND | MF_GRAYED); } else if (skin->GetUseD2D()) { CheckMenuItem(settingsMenu, IDM_SKIN_USED2D, MF_BYCOMMAND | MF_CHECKED); } } else { DeleteMenu(settingsMenu, IDM_SKIN_USED2D, MF_BYCOMMAND); } Gfx::CanvasD2D::Finalize(); if (skin->GetFavorite()) { CheckMenuItem(settingsMenu, IDM_SKIN_FAVORITE, MF_BYCOMMAND | MF_CHECKED); } } // Add the name of the Skin to the menu const std::wstring& skinName = skin->GetFolderPath(); ModifyMenu(skinMenu, IDM_SKIN_OPENSKINSFOLDER, MF_BYCOMMAND, IDM_SKIN_OPENSKINSFOLDER, skinName.c_str()); SetMenuDefaultItem(skinMenu, IDM_SKIN_OPENSKINSFOLDER, FALSE); // Remove dummy menuitem from the variants menu HMENU variantsMenu = GetSubMenu(skinMenu, 2); if (variantsMenu) { DeleteMenu(variantsMenu, 0, MF_BYPOSITION); } // Give the menuitem the unique id that depends on the skin ChangeSkinIndex(skinMenu, index); // Add the variants menu if (variantsMenu) { const SkinRegistry::Folder& skinFolder = *GetRainmeter().m_SkinRegistry.FindFolder(skinName); for (int i = 0, isize = (int)skinFolder.files.size(); i < isize; ++i) { InsertMenu(variantsMenu, i, MF_BYPOSITION, skinFolder.baseID + i, skinFolder.files[i].filename.c_str()); } if (skinFolder.active) { UINT checkPos = skinFolder.active - 1; CheckMenuRadioItem(variantsMenu, checkPos, checkPos, checkPos, MF_BYPOSITION); } } // Add skin root menu int itemCount = GetMenuItemCount(menu); if (itemCount > 0) { std::wstring root = skin->GetFolderPath(); std::wstring::size_type pos = root.find_first_of(L'\\'); if (pos != std::wstring::npos) { root.erase(pos); } // Skip "Open folder", "Disable dragging" and a separator for (int i = 3; i < itemCount; ++i) { const UINT state = GetMenuState(menu, i, MF_BYPOSITION); if (state == 0xFFFFFFFF || (state & MF_POPUP) == 0) break; WCHAR buffer[MAX_PATH]; if (GetMenuString(menu, i, buffer, MAX_PATH, MF_BYPOSITION)) { if (_wcsicmp(root.c_str(), buffer) == 0) { HMENU skinRootMenu = GetSubMenu(menu, i); if (skinRootMenu) { InsertMenu(skinMenu, 3, MF_BYPOSITION | MF_POPUP, (UINT_PTR)skinRootMenu, root.c_str()); } break; } } } } AppendSkinCustomMenu(skin, index, skinMenu, false); return skinMenu; }
// Process window messages LRESULT upsMenu::WndProcess(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) { switch (iMsg) { // User has clicked an item on the tray menu case WM_COMMAND: switch (LOWORD(wParam)) { case IDM_STATUS: // Show the status dialog _status.Show(); break; case IDM_EVENTS: // Show the Events dialog _events.Show(); break; case IDM_ABOUT: // Show the About box _about.Show(); break; case IDM_EXIT: // User selected Exit from the tray menu PostMessage(hwnd, WM_CLOSE, 0, 0); break; case IDM_REMOVE: // User selected Remove from the tray menu PostMessage(hwnd, WM_APCTRAY_REMOVE, 0, (LPARAM)(_config.id.str())); break; case IDM_REMOVEALL: // User wants to remove all apctray instances from registry PostMessage(hwnd, WM_APCTRAY_REMOVEALL, 0, 0); break; case IDM_ADD: // User selected Add from the tray menu PostMessage(hwnd, WM_APCTRAY_ADD, 0, 0); break; case IDM_CONFIG: // User selected Config from the tray menu _configdlg.Show(_config); break; case IDM_AUTOSTART: { MENUITEMINFO mii; mii.cbSize = sizeof(MENUITEMINFO); mii.fMask = MIIM_STATE; GetMenuItemInfo(_hsubmenu, IDM_AUTOSTART, FALSE, &mii); mii.fState ^= (MFS_CHECKED | MFS_UNCHECKED); SetMenuItemInfo(_hsubmenu, IDM_AUTOSTART, FALSE, &mii); _instmgr->SetAutoStart(mii.fState & MFS_CHECKED); break; } } return 0; // User has clicked on the tray icon or the menu case WM_APCTRAY_NOTIFY: // What event are we responding to, RMB click? if (lParam == WM_RBUTTONUP) { // Make the Status menu item the default (bold font) SetMenuDefaultItem(_hsubmenu, IDM_STATUS, false); // Set UPS name field ModifyMenu(_hsubmenu, IDM_NAME, MF_BYCOMMAND|MF_STRING, IDM_NAME, ("UPS: " + _upsname).str()); // Set HOST field char buf[100]; asnprintf(buf, sizeof(buf), "HOST: %s:%d", _config.host.str(), _config.port); ModifyMenu(_hsubmenu, IDM_HOST, MF_BYCOMMAND|MF_STRING, IDM_HOST, buf); // Set autostart field MENUITEMINFO mii; mii.cbSize = sizeof(MENUITEMINFO); mii.fMask = MIIM_STATE; mii.fState = MFS_ENABLED | _instmgr->IsAutoStart() ? MFS_CHECKED : MFS_UNCHECKED; SetMenuItemInfo(_hsubmenu, IDM_AUTOSTART, FALSE, &mii); // Get the current cursor position, to display the menu at POINT mouse; GetCursorPos(&mouse); // There's a "bug" (Microsoft calls it a feature) in Windows 95 that // requires calling SetForegroundWindow. To find out more, search for // Q135788 in MSDN. SetForegroundWindow(_hwnd); // Display the menu at the desired position TrackPopupMenu(_hsubmenu, 0, mouse.x, mouse.y, 0, _hwnd, NULL); } // Or was there a LMB double click? else if (lParam == WM_LBUTTONDBLCLK) { // double click: execute the default item SendMessage(_hwnd, WM_COMMAND, IDM_STATUS, 0); } return 0; // The user wants Apctray to quit cleanly... case WM_CLOSE: PostQuitMessage(0); return 0; default: if (iMsg == _tbcreated_msg) { // Explorer has restarted so we need to redraw the tray icon. // We purposely kick this out to the main loop instead of handling it // ourself so the icons are redrawn in a consistent order. PostMessage(hwnd, WM_APCTRAY_RESET, _generation++, 0); } break; } // Unknown message type return DefWindowProc(hwnd, iMsg, wParam, lParam); }
void update(HMENU hMenu, UINT pos, LPTSTR text) { if (!ModifyMenu(hMenu, pos, MF_BYCOMMAND|MF_STRING|MF_GRAYED, pos, text)) LOG_ERROR_TO_TRAY(_T("Failed to update menu: ") + error::lookup::last_error()); }
void win_update_menus(void) { bool shorts = !term.shortcut_override; bool clip = shorts && cfg.clip_shortcuts; bool alt_fn = shorts && cfg.alt_fn_shortcuts; bool ct_sh = shorts && cfg.ctrl_shift_shortcuts; ModifyMenu( sysmenu, IDM_NEW, 0, IDM_NEW, alt_fn ? "Ne&w\tAlt+F2" : ct_sh ? "Ne&w\tCtrl+Shift+N" : "Ne&w" ); ModifyMenu( sysmenu, SC_CLOSE, 0, SC_CLOSE, alt_fn ? "&Close\tAlt+F4" : ct_sh ? "&Close\tCtrl+Shift+W" : "&Close" ); uint sel_enabled = term.selected ? MF_ENABLED : MF_GRAYED; EnableMenuItem(menu, IDM_OPEN, sel_enabled); ModifyMenu( menu, IDM_COPY, sel_enabled, IDM_COPY, clip ? "&Copy\tCtrl+Ins" : ct_sh ? "&Copy\tCtrl+Shift+C" : "&Copy" ); uint paste_enabled = IsClipboardFormatAvailable(CF_TEXT) || IsClipboardFormatAvailable(CF_UNICODETEXT) || IsClipboardFormatAvailable(CF_HDROP) ? MF_ENABLED : MF_GRAYED; ModifyMenu( menu, IDM_PASTE, paste_enabled, IDM_PASTE, clip ? "&Paste\tShift+Ins" : ct_sh ? "&Paste\tCtrl+Shift+V" : "&Paste" ); ModifyMenu( menu, IDM_SEARCH, 0, IDM_SEARCH, alt_fn ? "S&earch\tAlt+F3" : ct_sh ? "S&earch\tCtrl+Shift+H" : "S&earch" ); ModifyMenu( menu, IDM_RESET, 0, IDM_RESET, alt_fn ? "&Reset\tAlt+F8" : ct_sh ? "&Reset\tCtrl+Shift+R" : "&Reset" ); uint defsize_enabled = IsZoomed(wnd) || term.cols != cfg.cols || term.rows != cfg.rows ? MF_ENABLED : MF_GRAYED; ModifyMenu( menu, IDM_DEFSIZE_ZOOM, defsize_enabled, IDM_DEFSIZE_ZOOM, alt_fn ? "&Default size\tAlt+F10" : ct_sh ? "&Default size\tCtrl+Shift+D" : "&Default size" ); uint fullscreen_checked = win_is_fullscreen ? MF_CHECKED : MF_UNCHECKED; ModifyMenu( menu, IDM_FULLSCREEN_ZOOM, fullscreen_checked, IDM_FULLSCREEN_ZOOM, alt_fn ? "&Full Screen\tAlt+F11" : ct_sh ? "&Full Screen\tCtrl+Shift+F" : "&Full Screen" ); uint otherscreen_checked = term.show_other_screen ? MF_CHECKED : MF_UNCHECKED; ModifyMenu( menu, IDM_FLIPSCREEN, otherscreen_checked, IDM_FLIPSCREEN, alt_fn ? "Flip &Screen\tAlt+F12" : ct_sh ? "Flip &Screen\tCtrl+Shift+S" : "Flip &Screen" ); uint options_enabled = config_wnd ? MF_GRAYED : MF_ENABLED; EnableMenuItem(menu, IDM_OPTIONS, options_enabled); EnableMenuItem(sysmenu, IDM_OPTIONS, options_enabled); }