mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 10:35:28 +00:00
[CONSRV] Cache the console window system menu handle; simplify its initialization code.
This commit is contained in:
parent
cf48f8bf8a
commit
0aed8b09a4
3 changed files with 29 additions and 24 deletions
|
@ -231,22 +231,25 @@ VOID
|
|||
CreateSysMenu(HWND hWnd)
|
||||
{
|
||||
MENUITEMINFOW mii;
|
||||
HMENU hMenu;
|
||||
PWCHAR ptrTab;
|
||||
WCHAR szMenuStringBack[255];
|
||||
WCHAR *ptrTab;
|
||||
HMENU hMenu = GetSystemMenu(hWnd, FALSE);
|
||||
if (hMenu != NULL)
|
||||
{
|
||||
|
||||
hMenu = GetSystemMenu(hWnd, FALSE);
|
||||
if (hMenu == NULL)
|
||||
return;
|
||||
|
||||
mii.cbSize = sizeof(mii);
|
||||
mii.fMask = MIIM_STRING;
|
||||
mii.dwTypeData = szMenuStringBack;
|
||||
mii.cch = sizeof(szMenuStringBack)/sizeof(WCHAR);
|
||||
mii.cch = ARRAYSIZE(szMenuStringBack);
|
||||
|
||||
GetMenuItemInfoW(hMenu, SC_CLOSE, FALSE, &mii);
|
||||
|
||||
ptrTab = wcschr(szMenuStringBack, '\t');
|
||||
ptrTab = wcschr(szMenuStringBack, L'\t');
|
||||
if (ptrTab)
|
||||
{
|
||||
*ptrTab = '\0';
|
||||
*ptrTab = L'\0';
|
||||
mii.cch = wcslen(szMenuStringBack);
|
||||
|
||||
SetMenuItemInfoW(hMenu, SC_CLOSE, FALSE, &mii);
|
||||
|
@ -254,7 +257,6 @@ CreateSysMenu(HWND hWnd)
|
|||
|
||||
AppendMenuItems(hMenu, GuiConsoleMainMenuItems);
|
||||
DrawMenuBar(hWnd);
|
||||
}
|
||||
}
|
||||
|
||||
static VOID
|
||||
|
@ -597,6 +599,7 @@ OnNcCreate(HWND hWnd, LPCREATESTRUCTW Create)
|
|||
Console = GuiData->Console;
|
||||
|
||||
GuiData->hWindow = hWnd;
|
||||
GuiData->hSysMenu = GetSystemMenu(hWnd, FALSE);
|
||||
|
||||
/* Initialize the fonts */
|
||||
if (!InitFonts(GuiData,
|
||||
|
@ -1370,6 +1373,7 @@ OnNcDestroy(HWND hWnd)
|
|||
/* Free the GuiData registration */
|
||||
SetWindowLongPtrW(hWnd, GWLP_USERDATA, (DWORD_PTR)NULL);
|
||||
|
||||
/* Reset the system menu back to default and destroy the previous menu */
|
||||
GetSystemMenu(hWnd, TRUE);
|
||||
|
||||
if (GuiData)
|
||||
|
|
|
@ -73,6 +73,7 @@ typedef struct _GUI_CONSOLE_DATA
|
|||
|
||||
BOOL HackCORE8394IgnoreNextMove; /* HACK FOR CORE-8394. See conwnd.c!OnMouse for more details. */
|
||||
|
||||
HMENU hSysMenu; /* Handle to the console window system menu */
|
||||
BOOL IsCloseButtonEnabled; /* TRUE if the Close button and the corresponding system menu item are enabled (default), FALSE otherwise */
|
||||
UINT CmdIdLow ; /* Lowest menu id of the user-reserved menu id range */
|
||||
UINT CmdIdHigh; /* Highest menu id of the user-reserved menu id range */
|
||||
|
|
|
@ -96,6 +96,7 @@ InvalidateCell(PGUI_CONSOLE_DATA GuiData,
|
|||
* GUI Terminal Initialization *
|
||||
******************************************************************************/
|
||||
|
||||
// FIXME: HACK: Potential HACK for CORE-8129; see revision 63595.
|
||||
VOID
|
||||
CreateSysMenu(HWND hWnd);
|
||||
|
||||
|
@ -1116,7 +1117,7 @@ GuiMenuControl(IN OUT PFRONTEND This,
|
|||
GuiData->CmdIdLow = CmdIdLow ;
|
||||
GuiData->CmdIdHigh = CmdIdHigh;
|
||||
|
||||
return GetSystemMenu(GuiData->hWindow, FALSE);
|
||||
return GuiData->hSysMenu;
|
||||
}
|
||||
|
||||
static BOOL NTAPI
|
||||
|
@ -1130,12 +1131,11 @@ GuiSetMenuClose(IN OUT PFRONTEND This,
|
|||
*/
|
||||
|
||||
PGUI_CONSOLE_DATA GuiData = This->Context;
|
||||
HMENU hSysMenu = GetSystemMenu(GuiData->hWindow, FALSE);
|
||||
|
||||
if (hSysMenu == NULL) return FALSE;
|
||||
if (GuiData->hSysMenu == NULL) return FALSE;
|
||||
|
||||
GuiData->IsCloseButtonEnabled = Enable;
|
||||
EnableMenuItem(hSysMenu, SC_CLOSE, MF_BYCOMMAND | (Enable ? MF_ENABLED : MF_GRAYED));
|
||||
EnableMenuItem(GuiData->hSysMenu, SC_CLOSE, MF_BYCOMMAND | (Enable ? MF_ENABLED : MF_GRAYED));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue