BOOL CALLBACK UpdMenu(HWND hwnd,LPARAM lParam) { int i; BOOL flag=lParam; // int Checked; HMENU hSysMenu=GetSystemMenu(hwnd, FALSE); for(i=0;i<GetMenuItemCount(hSysMenu) && hSysMenu;i++) if(GetMenuItemID(hSysMenu,i)==IDM_TRAY) hSysMenu = 0; if (hSysMenu && lParam) { InsertMenu (hSysMenu, GetMenuItemID(hSysMenu,0),MF_SEPARATOR,IDM_SEPARATOR, NULL) ; if(GetWindowLong(hwnd,GWL_EXSTYLE)&WS_EX_TOPMOST) InsertMenu (hSysMenu, GetMenuItemID(hSysMenu,0),MF_STRING|MF_CHECKED,IDM_ONTOP,"Always on top"); else InsertMenu (hSysMenu, GetMenuItemID(hSysMenu,0),MF_STRING,IDM_ONTOP,"Always on top"); InsertMenu (hSysMenu, GetMenuItemID(hSysMenu,0),MF_STRING,IDM_TRAY,"Minimize in tray"); InsertMenu (hSysMenu, GetMenuItemID(hSysMenu,0),MF_STRING,IDM_SIZE,"My size"); } if (hSysMenu && lParam==FALSE) { DeleteMenu (hSysMenu,IDM_TRAY,MF_BYCOMMAND); DeleteMenu (hSysMenu,IDM_ONTOP,MF_BYCOMMAND); DeleteMenu (hSysMenu,IDM_SEPARATOR,MF_BYCOMMAND); DeleteMenu (hSysMenu,IDM_SIZE,MF_BYCOMMAND); } return TRUE; }
////////////////////////////////////// // Create the window ////////////////////////////////////// HWND Create(HINSTANCE hInst, int nCmdShow) { RECT Rect; GetWindowRect(GetDesktopWindow(), &Rect); long ScreenW = Rect.right, ScreenH = Rect.bottom; global = (LPGLOBAL)malloc(sizeof(GLOBAL)); global->MainVar.MainhInst = hInst; global->MainVar.MainHwnd = CreateWindow(MAINWINDOW, MAINWINDOW, WS_BORDER | WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX | WS_MAXIMIZEBOX , 0, 0, ScreenW, ScreenH, NULL, NULL, hInst, NULL); DeleteMenu(GetSystemMenu(global->MainVar.MainHwnd, FALSE), SC_MOVE, MF_BYCOMMAND); DeleteMenu(GetSystemMenu(global->MainVar.MainHwnd, FALSE), SC_SIZE, MF_BYCOMMAND); if (global->MainVar.MainHwnd == NULL) return global->MainVar.MainHwnd; ShowWindow(global->MainVar.MainHwnd, nCmdShow); UpdateWindow(global->MainVar.MainHwnd); return global->MainVar.MainHwnd; }
static int mh_deleteitem (lua_State* l) { menu* m = lua_touserdata(l,1); if (lua_isnoneornil(l,2)) { const char* menuName = GetMenuName(m->parent, m->position); if (menuName) free(menuName); DeleteMenu(m->parent, m->command, MF_BYCOMMAND); if (!m->sub) { removeCustomCommand(m->command); removeAccelerator(m->command); } DrawMenuBar(win); return 0; } else { if (!m->sub) return 0; menu* x = lua_touserdata(l,2); const char* menuName = GetMenuName(m->menu, x->position); if (menuName) free(menuName); DeleteMenu(m->menu, x->command, MF_BYCOMMAND); DrawMenuBar(win); if (!x->sub) { removeCustomCommand(x->command); removeAccelerator(x->command); } lua_settop(l,1); return 1; }}
void update_item_menu(short mode) //mode 0 - display item menus 1 - lock menus { short i,j; HMENU menu[10],big_menu; char item_name[256]; big_menu = GetMenu(mainPtr); for (i = 0; i < 10; i++) menu[i] = GetSubMenu(big_menu,3 + i); for(j=0;j<10;j++){ //first let's clean the menu DeleteMenu(menu[j],1000 + j,MF_BYCOMMAND); //If there is any dummy, flush it for (i=0;i<40;i++) DeleteMenu(menu[j],600+(40*j)+i,MF_BYCOMMAND); } switch(mode){ case 0: for (j = 0; j < 10; j++) { //then populate it for (i = 0; i < 40; i++) { sprintf(item_name, "%s",scen_item_list.scen_items[i + j * 40].full_name); if ((i % 20 == 0) && (i > 0)) AppendMenu(menu[j],MF_MENUBREAK | MF_BYCOMMAND | MF_ENABLED | MF_STRING, 600 + (40 * j) + i, item_name); else AppendMenu(menu[j],MF_BYCOMMAND | MF_ENABLED | MF_STRING, 600 + (40 * j) + i, item_name); } } break; case 1: for (j = 0; j < 10; j++) //then lock menus AppendMenu(menu[j],MF_MENUBREAK | MF_BYCOMMAND | MF_GRAYED | MF_STRING, 600 + (40 * j), "None"); break; } }
VOID FreeLogList(void) { DWORD dwIndex; if (!LogNames) { return; } for (dwIndex = 0; dwIndex < dwNumLogs; dwIndex++) { if (LogNames[dwIndex]) { HeapFree(GetProcessHeap(), 0, LogNames[dwIndex]); } DeleteMenu(hMainMenu, ID_FIRST_LOG + dwIndex, MF_BYCOMMAND); } DeleteMenu(hMainMenu, ID_FIRST_LOG + dwIndex + 1, MF_BYCOMMAND); HeapFree(GetProcessHeap(), 0, LogNames); dwNumLogs = 0; return; }
/*****************************Private*Routine******************************\ * GetRecentFiles * * Reads at most MAX_RECENT_FILES from the app's registry entry. * Returns the number of files actually read. * Updates the File menu to show the "recent" files. * \**************************************************************************/ int GetRecentFiles( int iLastCount, int iMenuPosition // Menu position of start of MRU list ) { int i; TCHAR FileName[MAX_PATH]; TCHAR szKey[32]; HMENU hSubMenu; // // Delete the files from the menu // hSubMenu = GetSubMenu(GetMenu(hwndApp), 0); // Delete the separator at the requested position and all the other // recent file entries if(iLastCount != 0) { DeleteMenu(hSubMenu, iMenuPosition, MF_BYPOSITION); for(i = 1; i <= iLastCount; i++) { DeleteMenu(hSubMenu, ID_RECENT_FILE_BASE + i, MF_BYCOMMAND); } } for(i = 1; i <= MAX_RECENT_FILES; i++) { DWORD len; TCHAR szMenuName[MAX_PATH + 3]; (void)StringCchPrintf(szKey, NUMELMS(szKey), TEXT("File %d\0"), i); len = ProfileStringIn(szKey, TEXT(""), FileName, MAX_PATH * sizeof(TCHAR)); if(len == 0) { i = i - 1; break; } StringCchCopy(aRecentFiles[i - 1], NUMELMS(aRecentFiles[i-1]), FileName); (void)StringCchPrintf(szMenuName, NUMELMS(szMenuName), TEXT("&%d %s\0"), i, FileName); if(i == 1) { InsertMenu(hSubMenu, iMenuPosition, MF_SEPARATOR | MF_BYPOSITION, (UINT)-1, NULL); } InsertMenu(hSubMenu, iMenuPosition + i, MF_STRING | MF_BYPOSITION, ID_RECENT_FILE_BASE + i, szMenuName); } // // i is the number of recent files in the array. // return i; }
/****************************************************************************** * void SetMruMenu(HWND hwnd) * * update the mru menu items according to the changed mru list * * parameters: * hwnd - window handle of window with mru menu items * * notes: * The mru list appears in the File menu for the window's menu bar. * The file menu can be the first (0th) or second (1th) by_position * depending on whether the mdi child is maximized (see mmenu.c MenuStatus()). * * Assumes the file menu last two items initially are a separator followed * by a menu item (exit). Inserts mru items following the separator followed * by a new separator. ******************************************************************************/ static void SetMruMenu(HWND hwnd) { char sz[sizeof("&1 ") + _MAX_PATH]; char *psz; HMENU hMenu = GetMenu(hwnd); int i; int nExit; /* find the File menu */ assert(hMenu != 0); if ( hMenu == 0 ) return; GetMenuString(hMenu, 1, sz, sizeof(sz), MF_BYPOSITION); if ( stricmp(sz, "&File") == 0 ) hMenu = GetSubMenu(hMenu, 1); else hMenu = GetSubMenu(hMenu, 0); assert(hMenu != 0); if ( hMenu == 0 ) return; /* delete any mru items presently in the file menu */ for ( i = 0; i < MAX_MRUFILES; i++ ) DeleteMenu(hMenu, IDM_FILE_MRUFILE1 + i, MF_BYCOMMAND); /* if the 3rd entry from the bottom is a separator, then we assume it's the one we inserted for the mru section, and delete it (to be reinserted below) */ i = GetMenuItemCount(hMenu); nExit = GetMenuItemID(hMenu, i - 1); if ( GetMenuItemID(hMenu, i - 3) == 0 ) DeleteMenu(hMenu, i - 3, MF_BYPOSITION); if ( arszMruFilenames[0][0] != '\0' ) { /* insert mru file names */ for ( i = 0; i < MAX_MRUFILES && *arszMruFilenames[i] != '\0'; i++ ) { wsprintf(sz, "&%d ", i + 1); psz = sz + strlen(sz); MiscShortFilename( arszMruFilenames[i], psz, sizeof("C:\\...\\PATHNAME.EXT\\FILENAME.EXT") - 1); InsertMenu( hMenu, nExit, MF_BYCOMMAND | MF_STRING, IDM_FILE_MRUFILE1 + i, sz ); } /* (re)insert separator preceding File/Exit */ InsertMenu(hMenu, nExit, MF_BYCOMMAND | MF_SEPARATOR, 0, 0); } }
void CAppWindow::ShowContextMenu() { if (!AllowContextMenu()) { return; } if (CPopupWindow::Instance() != NULL) { CPopupWindow::Instance()->CancelAll(); } if (m_hPopupMenus != NULL) { DestroyMenu(m_hPopupMenus); } m_hPopupMenus = LoadMenu(CApp::Instance()->GetInstance(), MAKEINTRESOURCE(IDR_POPUP_MENUS)); HMENU hSubMenu = GetSubMenu(m_hPopupMenus, 0); if (m_lpSession->GetState() == WSS_ONLINE || m_lpSession->GetState() == WSS_RECONNECTING) { DeleteMenu(hSubMenu, ID_TRAYICON_LOGIN, MF_BYCOMMAND); } else { DeleteMenu(hSubMenu, ID_TRAYICON_SIGNOUT, MF_BYCOMMAND); EnableMenuItem(hSubMenu, ID_TRAYICON_INBOX, MF_GRAYED | MF_BYCOMMAND); EnableMenuItem(hSubMenu, ID_TRAYICON_CHECKWAVESNOW, MF_GRAYED | MF_BYCOMMAND); } if (CVersion::Instance()->GetState() != VS_NONE) { EnableMenuItem(hSubMenu, ID_TRAYICON_CHECKFORUPDATESNOW, MF_GRAYED | MF_BYCOMMAND); } POINT p; GetCursorPos(&p); SetForegroundWindow(GetHandle()); TrackPopupMenuEx( hSubMenu, TPM_VERTICAL | TPM_RIGHTALIGN, p.x, p.y, GetHandle(), NULL); PostMessage(WM_NULL); }
int stop_thread_menu(int create) { if(create){ DeleteMenu(ghmenu,IDM_STOP_THREAD,MF_BYCOMMAND); InsertMenu(ghmenu,IDM_STOP_THREAD,MF_BYCOMMAND|MF_STRING,IDM_STOP_THREAD,"Cancel thread"); } else{ DeleteMenu(ghmenu,IDM_STOP_THREAD,MF_BYCOMMAND); } DrawMenuBar(ghmainframe); return 0; }
//--------------------------------------------------------------------- // InitializePopup(): //--------------------------------------------------------------------- void WPDIRECTORY::InitializePopup(HMENU hmenuPopup) { // Call base class function. WPFOLDER::InitializePopup(hmenuPopup); // Delete menu item "Create another..." in folder popup menu. DeleteMenu(hmenuPopup,IDM_CREATEANOTHER,MF_BYCOMMAND); // Delete menu item "Create shadow..." in folder popup menu. DeleteMenu(hmenuPopup,IDM_CREATESHADOW,MF_BYCOMMAND); // Delete menu item "Delete..." in folder popup menu. DeleteMenu(hmenuPopup,IDM_FIND,MF_BYCOMMAND); }
void WMDeleteMenu(short menuID) { if (!CheckRunningInMainThread("WMDeleteMenu")) return; DeleteMenu(menuID); }
VOID NEAR PASCAL BiasMenu(HMENU hMenu, INT Bias) { INT pos, id, count; HMENU hSubMenu; CHAR szMenuString[80]; ENTER("BiasMenu"); count = GetMenuItemCount(hMenu); if (count < 0) return; for (pos = 0; pos < count; pos++) { id = GetMenuItemID(hMenu, pos); if (id < 0) { // must be a popup, recurse and update all ID's here if (hSubMenu = GetSubMenu(hMenu, pos)) BiasMenu(hSubMenu, Bias); } else if (id) { // replace the item that was there with a new // one with the id adjusted GetMenuString(hMenu, (WORD)pos, szMenuString, sizeof(szMenuString), MF_BYPOSITION); DeleteMenu(hMenu, pos, MF_BYPOSITION); InsertMenu(hMenu, (WORD)pos, MF_BYPOSITION | MF_STRING, id + Bias, szMenuString); } } LEAVE("BiasMenu"); }
/* Delete the specified blink manager entry. */ void FASTCALL DeleteBlinkManagerEntry( LPBLINKENTRY lpbe ) { /* First unlink this entry from * the list. */ if( lpbe->lpbePrev ) lpbe->lpbePrev->lpbeNext = lpbe->lpbeNext; else lpbeFirst = lpbe->lpbeNext; if( lpbe->lpbeNext ) lpbe->lpbeNext->lpbePrev = lpbe->lpbePrev; /* Delete the associated command from the * command table. This will also remove any * toolbar button. */ CTree_DeleteCommand( lpbe->iCommandID ); /* Delete from the Blink menu. */ DeleteMenu( hBlinkMenu, lpbe->iCommandID, MF_BYCOMMAND ); /* Delete from the registry. */ Amuser_WritePPString( szBlinkman, lpbe->szName, NULL ); /* Free the allocated memory. */ FreeMemory( &lpbe ); }
static bool LuaGuiDeleteMenu(void *hMenu, uint32_t position, uint32_t flag) { return !! DeleteMenu( reinterpret_cast<HMENU>(hMenu), position, flag); }
// /// Merges the functional groups of another menu descriptor into this menu /// descriptor. /// /// Popups are DeepCopied and are then owned by this menu /// Group counts are merged too. // bool TMenuDescr::Merge(const TMenuDescr& srcMenuDescr) { int thisOffset = 0; int srcOffset = 0; for (int i = 0; i < NumGroups; i++) { if (srcMenuDescr.GroupCount[i] != 0) { // Delete same menu group in the dest. menudescr. for (int j = GroupCount[i] - 1; j >= 0; j--) { DeleteMenu(thisOffset+j, MF_BYPOSITION); } GroupCount[i] = 0; if (srcMenuDescr.GroupCount[i] > 0) { DeepCopy(*this, thisOffset, srcMenuDescr, srcOffset, srcMenuDescr.GroupCount[i]); srcOffset += srcMenuDescr.GroupCount[i]; GroupCount[i] += srcMenuDescr.GroupCount[i]; } } if (GroupCount[i] > 0) thisOffset += GroupCount[i]; } return true; }
static void DeleteSubMenus(SubSysMenuHandle subSysMenus) // Remove any sub-menus that we added to the menu bar. // Basically this just walks subSysMenus (backwards, which // isn't strictly necessary, but reassures me that the menu // bar is somewhat consistent at each step), deleting each // menu from the menu bar and reseting its parent to reference // menu ID 0. { ItemCount entryCount; ItemCount entryIndex; SubSysMenuEntry thisEntry; // Have to handle both NULL and non-NULL case. // This expression always evaluates to true, // but it captures the semantics of what this // routine must do. assert(subSysMenus != NULL || subSysMenus == NULL); entryCount = CountSubSysMenus(subSysMenus); for (entryIndex = 0; entryIndex < entryCount; entryIndex++) { thisEntry = (*subSysMenus)[entryCount - entryIndex - 1]; DeleteMenu( (**(thisEntry.childMenu)).menuID ); SetItemMark( thisEntry.parentMenu, thisEntry.itemInParent, 0); // Recalculate the parent menu size, for consistency with // the similar code in InsertSystemSubMenu. CalcMenuSize(thisEntry.parentMenu); } }
LRESULT CDuilib3dFrame::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { LONG styleValue = ::GetWindowLong(*this, GWL_STYLE); styleValue &= ~WS_CAPTION; styleValue &= ~WS_THICKFRAME; ::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN); HMENU hMenu = GetSystemMenu(m_hWnd,FALSE); if (hMenu != NULL) { DeleteMenu(hMenu,SC_MAXIMIZE,MF_BYCOMMAND); } //根据skin.xml创建程序界面 m_PaintManager.Init(m_hWnd); CDialogBuilder builder; CDialogBuilderCallbackEx cb; CControlUI* pRoot = builder.Create(_T("skin.xml"), (UINT)0, &cb, &m_PaintManager); ASSERT(pRoot && "Failed to parse XML"); m_PaintManager.AttachDialog(pRoot); m_PaintManager.AddNotifier(this); HICON hIcon = LoadIcon((HINSTANCE)GetWindowLong(m_hWnd,GWL_HINSTANCE),MAKEINTRESOURCE(IDI_ICON)); m_tray.Create(m_hWnd,WM_USER+1021,_T("360安全卫士"),hIcon,NULL); return 0; }
/* to reflect the shift in position */ void StMObDeleteItem(LVAL menu, LVAL item) { HMENU addr; int n, i, j, id, flags; LVAL items; char *s; if (StMObAllocated(menu)) { addr = get_menu_address(menu); id = get_menu_id(menu); i = get_item_position(menu, item); for (j = 0, items = slot_value(menu, s_items); j < i && consp(items); j++, items = cdr(items)); n = GetMenuItemCount((HMENU) addr); for (; i < n; n--) DeleteMenu((HMENU) addr, i, MF_BYPOSITION); if (consp(items)) items = cdr(items); for (; consp(items); items = cdr(items), i++) { item = car(items); s = get_item_string(item); if (s[0] == '-') AppendMenu((HMENU) addr, MF_SEPARATOR, 0, NULL); else { flags = MF_STRING; if (slot_value(item, s_mark) != NIL) flags |= MF_CHECKED; if (slot_value(item, s_enabled) == NIL) flags |= MF_GRAYED; AppendMenu((HMENU) addr, flags, MAKEITEMINDEX(id, i), s); } } } }
BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { g_hModule = (HMODULE)hModule; if (ul_reason_for_call == DLL_PROCESS_ATTACH) { ProcessAttach(); AddMenu(); ::MessageBox(NULL, "我来了", NULL, MB_OK); } else if (ul_reason_for_call == DLL_PROCESS_DETACH) { ProcessDetach(); assert(g_hMenu != NULL); BOOL bRet = DeleteMenu(g_hMenu, g_nMenus - 1, MF_BYPOSITION); if (!bRet) { MessageBox(NULL, "DeleteMenu Failed!!", NULL, MB_OK); } ::MessageBox(NULL, "我走了", NULL, MB_OK); } return TRUE; }
/// <summary>Creates the console</summary> ConsoleWnd::ConsoleWnd() : Handle(nullptr) { // Create console if (AllocConsole()) { // Get handle SetConsoleTitle(L"Debug Console"); Handle = GetStdHandle(STD_OUTPUT_HANDLE); // Increase buffer size COORD buf { 200, 6*1000 }; SetConsoleScreenBufferSize(Handle, buf); // Increate window size //SMALL_RECT wnd { 0, 0, buf.X-2, buf.Y-2}; //SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), TRUE, &wnd); // Disable close button DeleteMenu(GetSystemMenu(GetConsoleWindow(), 0), SC_CLOSE, MF_BYCOMMAND); // Maximize ShowWindow(GetConsoleWindow(), SW_MAXIMIZE); #ifdef OFFICIAL_RELEASE // Initially hide Visible = false; #endif } }
/************************************************************************* * FileMenu_DeleteAllItems [SHELL32.104] * * NOTES * exported by name */ BOOL WINAPI FileMenu_DeleteAllItems (HMENU hmenu) { MENUITEMINFOW mii; LPFMINFO menudata; int i; TRACE("%p\n", hmenu); ZeroMemory ( &mii, sizeof(MENUITEMINFOW)); mii.cbSize = sizeof(MENUITEMINFOW); mii.fMask = MIIM_SUBMENU|MIIM_DATA; for (i = 0; i < GetMenuItemCount( hmenu ); i++) { GetMenuItemInfoW(hmenu, i, TRUE, &mii ); SHFree((LPFMINFO)mii.dwItemData); if (mii.hSubMenu) FileMenu_Destroy(mii.hSubMenu); } while (DeleteMenu (hmenu, 0, MF_BYPOSITION)){}; menudata = FM_GetMenuInfo(hmenu); menudata->bInitialized = FALSE; return TRUE; }
VOID RemoveMenu(HWND hwnd, HMENU menu) { if (bAddedMenu == false) return; HMENU systemMenu; if ((systemMenu = GetSystemMenu(hwnd, FALSE)) == NULL) { return; } if (menu != INVALID_HANDLE_VALUE && menu != systemMenu) { return; } bAddedMenu = false; MENUITEMINFO MoveToItem = { 0 }; MoveToItem.cbSize = sizeof(MoveToItem); MoveToItem.fMask = MIIM_SUBMENU | MIIM_STATE | MIIM_ID | MIIM_STRING; if (GetMenuItemInfo(systemMenu, MOVETOMENU_ID, MF_BYCOMMAND, &MoveToItem) == NULL) { return; } Log("Remove MoveToMenu"); DestroyMenu(MoveToItem.hSubMenu); DeleteMenu(systemMenu, MoveToItem.wID, MF_BYCOMMAND); }
void Explorerplusplus::OnApplicationToolbarRClick() { MENUITEMINFO mii; TCHAR szTemp[64]; LoadString(m_hLanguageModule,IDS_APPLICATIONBUTTON_NEW, szTemp,SIZEOF_ARRAY(szTemp)); mii.cbSize = sizeof(mii); mii.fMask = MIIM_ID|MIIM_STRING; mii.dwTypeData = szTemp; mii.wID = IDM_APP_NEW; /* Add the item to the menu. */ InsertMenuItem(m_hToolbarRightClickMenu,7,TRUE,&mii); /* Set it to be owner drawn. */ SetMenuItemOwnerDrawn(m_hToolbarRightClickMenu,7); OnMainToolbarRClick(); mii.cbSize = sizeof(mii); mii.fMask = MIIM_DATA; GetMenuItemInfo(m_hToolbarRightClickMenu,7,TRUE,&mii); /* Free the owner drawn data. */ free((void *)mii.dwItemData); /* Now, remove the item from the menu. */ DeleteMenu(m_hToolbarRightClickMenu,7,MF_BYPOSITION); }
void FillBSPMenu( void ) { HMENU hmenu; epair_s* ep; int i; static int count; hmenu = GetSubMenu( GetMenu( g_qeglobals.d_hwndMain ), MENU_BSP ); for ( i = 0 ; i < count ; i++ ) DeleteMenu( hmenu, CMD_BSPCOMMAND + i, MF_BYCOMMAND ); count = 0; i = 0; for ( ep = g_qeglobals.d_project_entity->epairs ; ep ; ep = ep->next ) { if ( ep->key[0] == 'b' && ep->key[1] == 's' && ep->key[2] == 'p' ) { bsp_commands[i] = ep->key; AppendMenu( hmenu, MF_ENABLED | MF_STRING, CMD_BSPCOMMAND + i, ( LPCTSTR )ep->key ); i++; } } count = i; }
void createWindowsConsole() { if(consoleWindow !=0) return; //create a console on Windows so users can see messages //find an available name for our window int console_suffix = 0; char consoleTitle[512]; sprintf(consoleTitle, "%s", "Gource Console"); while(FindWindow(0, consoleTitle)) { sprintf(consoleTitle, "Gource Console %d", ++console_suffix); } AllocConsole(); SetConsoleTitle(consoleTitle); //redirect streams to console freopen("conin$", "r", stdin); freopen("conout$","w", stdout); freopen("conout$","w", stderr); consoleWindow = 0; //wait for our console window while(consoleWindow==0) { consoleWindow = FindWindow(0, consoleTitle); SDL_Delay(100); } //disable the close button so the user cant crash gource HMENU hm = GetSystemMenu(consoleWindow, false); DeleteMenu(hm, SC_CLOSE, MF_BYCOMMAND); }
boolean clickcolorpopup (Point pt, RGBColor *rgb) { long result; short lo, hi; if (!flpopupinit) flpopupinit = initcolorpopup (); setcursortype (cursorisarrow); CalcMenuSize (colormenu); InsertMenu (colormenu, hierMenu); LocalToGlobal (&pt); result = PopUpMenuSelect (colormenu, pt.v, pt.h, -1); DeleteMenu ((**colormenu).menuID); lo = LoWord (result); hi = HiWord (result); if (hi > 0) { /*something was selected*/ *rgb = (*ctable) [lo - 1].rgb; return (true); } return (false); } /*clickcolorpopup*/
void MenuWindow::MessageReceived(BMessage* message) { switch (message->what) { case MSG_WIN_ADD_MENU: AddMenu(message); break; case MSG_WIN_DELETE_MENU: DeleteMenu(message); break; case MSG_TEST_ITEM: TestMenu(message); break; case MSG_USER_ITEM: UserMenu(message); break; case MSG_WIN_HIDE_USER_MENUS: ToggleUserMenus(message); break; case MSG_WIN_LARGE_TEST_ICONS: ToggleTestIcons(message); break; default: BWindow::MessageReceived(message); break; } }
bool DeleteMenu(HMENU hMenu, int idx, int flag) { if (!hMenu) return false; if (flag&MF_BYPOSITION) { if (hMenu->items.Get(idx)) { hMenu->items.Delete(idx,true,HMENU__::freeMenuItem); return true; } return false; } else { int x; int cnt=0; for (x=0;x<hMenu->items.GetSize(); x ++) { if (!hMenu->items.Get(x)->hSubMenu && hMenu->items.Get(x)->wID == idx) { hMenu->items.Delete(x--,true,HMENU__::freeMenuItem); cnt++; } } if (!cnt) { for (x=0;x<hMenu->items.GetSize(); x ++) { if (hMenu->items.Get(x)->hSubMenu) cnt += DeleteMenu(hMenu->items.Get(x)->hSubMenu,idx,flag)?1:0; } } return !!cnt; } }
/*! コンテキストメニュー呼びだしアクション(要は右クルック) @param[in] hWnd ウインドウハンドル @param[in] hWndContext コンテキストが発生したウインドウのハンドル @param[in] xPos スクリーンX座標 @param[in] yPos スクリーンY座業 @return 無し */ VOID Drt_OnContextMenu( HWND hWnd, HWND hWndContext, UINT xPos, UINT yPos ) { HMENU hMenu, hSubMenu; UINT dRslt; POINT stPoint, stPos; stPoint.x = (SHORT)xPos; // 画面座標はマイナスもありうる stPoint.y = (SHORT)yPos; TRACE( TEXT("CTX %d x %d"), stPoint.x, stPoint.y ); stPos = stPoint; ScreenToClient( hWnd, &stPos ); giTarget = DraughtTargetItemSet( &stPos ); TRACE( TEXT("TARGET %d"), giTarget ); hMenu = LoadMenu( GetModuleHandle(NULL), MAKEINTRESOURCE(IDM_DRAUGHT_POPUP) ); hSubMenu = GetSubMenu( hMenu, 0 ); if( gbThumb ) // サムネ側なら { DeleteMenu( hSubMenu, IDM_DRAUGHT_ALLDELETE, MF_BYCOMMAND ); // 全削除を破壊 DeleteMenu( hSubMenu, IDM_DRAUGHT_EXPORT, MF_BYCOMMAND ); // エクスポートを破壊 // 文字列変更 ModifyMenu( hSubMenu, IDM_DRAUGHT_CLOSE, MF_BYCOMMAND | MFT_STRING, IDM_DRAUGHT_CLOSE, TEXT("サムネイルを閉じる(&Q)") ); ModifyMenu( hSubMenu, IDM_DRAUGHT_DELETE, MF_BYCOMMAND | MFT_STRING, IDM_THUMB_DRAUGHT_ADD, TEXT("ドラフトボードに追加(&D)") ); } if( giItemWidth == giItemHeight ) // 該当するサイズにチェキラ! { switch( giItemWidth ) { case DTHMSZ_ULTRALIGHT: CheckMenuItem( hSubMenu, IDM_DB_THUMB_ULTRALIGHT, MF_CHECKED ); break; case DTHMSZ_REGULAR: CheckMenuItem( hSubMenu, IDM_DB_THUMB_REGULAR, MF_CHECKED ); break; case DTHMSZ_DEMIBOLD: CheckMenuItem( hSubMenu, IDM_DB_THUMB_DEMIBOLD, MF_CHECKED ); break; case DTHMSZ_ULTRABOLD: CheckMenuItem( hSubMenu, IDM_DB_THUMB_ULTRABOLD, MF_CHECKED ); break; default: break; } } dRslt = TrackPopupMenu( hSubMenu, 0, stPoint.x, stPoint.y, 0, hWnd, NULL ); // 選択せずで0か−1?、TPM_RETURNCMD無かったら、選択したらそのメニューのIDでWM_COMMANDが発行 DestroyMenu( hMenu ); return; }
void ObjUpdateMenuVerbs( HMENU hMenu ) { int cObjects; extern struct SEL selCur; extern char szOPropMenuStr[]; extern char szPPropMenuStr[]; extern BOOL vfOutOfMemory; char szBuffer[cchMaxSz]; char szWordOrder2[10], szWordOrder3[10]; if (vfOutOfMemory) { EnableMenuItem(hMenu, EDITMENUPOS, MF_GRAYED|MF_BYPOSITION); return; } LoadString(hINSTANCE, IDSTRPopupVerbs, szWordOrder2, sizeof(szWordOrder2)); LoadString(hINSTANCE, IDSTRSingleVerb, szWordOrder3, sizeof(szWordOrder3)); DeleteMenu(hMenu, EDITMENUPOS, MF_BYPOSITION); /** Cases: 0) 0 objects selected 1) 1 object selected a) object supports 0 verbs "Edit <Object Class> Object" b) object supports more than 1 verb "<Object Class> Object" => verbs 2) more than 1 object selected "Objects" Use the VerbMenu strings to determine the order in which these words should appear in the menu string (for localization). **/ /* how many objects are selected? */ cObjects = ObjSetSelectionType(docCur,selCur.cpFirst, selCur.cpLim); /* must be only an object, not text in selection */ if (cObjects == 1) { ObjCachePara(docCur,selCur.cpFirst); if (!ObjQueryCpIsObject(docCur,selCur.cpFirst)) cObjects = 0; } if ((cObjects == -1) // error || (cObjects == 0) || (cObjects > 1)) { wsprintf(szBuffer, "%s", (LPSTR)((cObjects > 1) ? szPPropMenuStr : szOPropMenuStr)); InsertMenu(hMenu, EDITMENUPOS, MF_BYPOSITION,imiVerb,szBuffer); /* Spec says if > 1 then optionally should enable if all servers are of the same class. I'm opting not to implement. (9.27.91) v-dougk */ EnableMenuItem(hMenu, EDITMENUPOS, MF_GRAYED | MF_BYPOSITION); #if 0 else // > 1 {