/*static*/ VOID CreateVdmMenu(HANDLE ConOutHandle) { hConsoleMenu = ConsoleMenuControl(ConOutHandle, ID_SHOWHIDE_MOUSE, ID_VDM_QUIT); if (hConsoleMenu == NULL) return; VdmMenuPos = GetMenuItemCount(hConsoleMenu); AppendMenuItems(hConsoleMenu, VdmMainMenuItems); DrawMenuBar(GetConsoleWindow()); }
static VOID AppendMenuItems(HMENU hMenu, const VDM_MENUITEM *Items) { UINT i = 0; WCHAR szMenuString[256]; HMENU hSubMenu; do { if (Items[i].uID != (UINT)-1) { if (LoadStringW(GetModuleHandle(NULL), Items[i].uID, szMenuString, ARRAYSIZE(szMenuString)) > 0) { if (Items[i].SubMenu != NULL) { hSubMenu = CreatePopupMenu(); if (hSubMenu != NULL) { AppendMenuItems(hSubMenu, Items[i].SubMenu); if (!AppendMenuW(hMenu, MF_STRING | MF_POPUP, (UINT_PTR)hSubMenu, szMenuString)) { DestroyMenu(hSubMenu); } } } else { AppendMenuW(hMenu, MF_STRING, Items[i].uCmdID, szMenuString); } } } else { AppendMenuW(hMenu, MF_SEPARATOR, 0, NULL); } i++; } while (!(Items[i].uID == 0 && Items[i].SubMenu == NULL && Items[i].uCmdID == 0)); }
static VOID CreateVdmMenu(HANDLE ConOutHandle) { HMENU hVdmSubMenu; UINT_PTR ItemID; UINT Pos; USHORT i; WCHAR szNoMedia[100]; WCHAR szMenuString1[256], szMenuString2[256]; hConsoleMenu = ConsoleMenuControl(ConOutHandle, ID_CAPTURE_MOUSE, ID_VDM_DRIVES + (2 * ARRAYSIZE(GlobalSettings.FloppyDisks))); if (hConsoleMenu == NULL) return; /* Get the position where we are going to insert our menu items */ VdmMenuPos = GetMenuItemCount(hConsoleMenu); /* Really add the menu if it doesn't already exist (in case eg. NTVDM crashed) */ if (!VdmMenuExists(hConsoleMenu)) { /* Add all the menu entries */ AppendMenuItems(hConsoleMenu, VdmMainMenuItems); /* Add the removable drives menu entries */ hVdmSubMenu = GetSubMenu(hConsoleMenu, VdmMenuPos + 2); // VdmMenuItems Pos = 3; // After the 2 items and the separator in VdmMenuItems LoadStringW(GetModuleHandle(NULL), IDS_NO_MEDIA, szNoMedia, ARRAYSIZE(szNoMedia)); LoadStringW(GetModuleHandle(NULL), IDS_VDM_MOUNT_FLOPPY, szMenuString1, ARRAYSIZE(szMenuString1)); /* Drive 'x' -- Mount */ for (i = 0; i < ARRAYSIZE(GlobalSettings.FloppyDisks); ++i) { ItemID = ID_VDM_DRIVES + (2 * i); /* Add the item */ _snwprintf(szMenuString2, ARRAYSIZE(szMenuString2), szMenuString1, i, szNoMedia); szMenuString2[ARRAYSIZE(szMenuString2) - 1] = UNICODE_NULL; InsertMenuW(hVdmSubMenu, Pos++, MF_STRING | MF_BYPOSITION, ItemID, szMenuString2); } LoadStringW(GetModuleHandle(NULL), IDS_VDM_EJECT_FLOPPY, szMenuString1, ARRAYSIZE(szMenuString1)); /* Drive 'x' -- Eject */ for (i = 0; i < ARRAYSIZE(GlobalSettings.FloppyDisks); ++i) { ItemID = ID_VDM_DRIVES + (2 * i); /* Add the item */ _snwprintf(szMenuString2, ARRAYSIZE(szMenuString2), szMenuString1, i); szMenuString2[ARRAYSIZE(szMenuString2) - 1] = UNICODE_NULL; InsertMenuW(hVdmSubMenu, Pos++, MF_STRING | MF_BYPOSITION, ItemID + 1, szMenuString2); } /* Refresh the menu state */ UpdateVdmMenu(); DrawMenuBar(hConsoleWnd); } }