mirror of
https://github.com/reactos/reactos.git
synced 2025-01-01 12:04:51 +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)
|
CreateSysMenu(HWND hWnd)
|
||||||
{
|
{
|
||||||
MENUITEMINFOW mii;
|
MENUITEMINFOW mii;
|
||||||
|
HMENU hMenu;
|
||||||
|
PWCHAR ptrTab;
|
||||||
WCHAR szMenuStringBack[255];
|
WCHAR szMenuStringBack[255];
|
||||||
WCHAR *ptrTab;
|
|
||||||
HMENU hMenu = GetSystemMenu(hWnd, FALSE);
|
hMenu = GetSystemMenu(hWnd, FALSE);
|
||||||
if (hMenu != NULL)
|
if (hMenu == NULL)
|
||||||
{
|
return;
|
||||||
|
|
||||||
mii.cbSize = sizeof(mii);
|
mii.cbSize = sizeof(mii);
|
||||||
mii.fMask = MIIM_STRING;
|
mii.fMask = MIIM_STRING;
|
||||||
mii.dwTypeData = szMenuStringBack;
|
mii.dwTypeData = szMenuStringBack;
|
||||||
mii.cch = sizeof(szMenuStringBack)/sizeof(WCHAR);
|
mii.cch = ARRAYSIZE(szMenuStringBack);
|
||||||
|
|
||||||
GetMenuItemInfoW(hMenu, SC_CLOSE, FALSE, &mii);
|
GetMenuItemInfoW(hMenu, SC_CLOSE, FALSE, &mii);
|
||||||
|
|
||||||
ptrTab = wcschr(szMenuStringBack, '\t');
|
ptrTab = wcschr(szMenuStringBack, L'\t');
|
||||||
if (ptrTab)
|
if (ptrTab)
|
||||||
{
|
{
|
||||||
*ptrTab = '\0';
|
*ptrTab = L'\0';
|
||||||
mii.cch = wcslen(szMenuStringBack);
|
mii.cch = wcslen(szMenuStringBack);
|
||||||
|
|
||||||
SetMenuItemInfoW(hMenu, SC_CLOSE, FALSE, &mii);
|
SetMenuItemInfoW(hMenu, SC_CLOSE, FALSE, &mii);
|
||||||
|
@ -254,7 +257,6 @@ CreateSysMenu(HWND hWnd)
|
||||||
|
|
||||||
AppendMenuItems(hMenu, GuiConsoleMainMenuItems);
|
AppendMenuItems(hMenu, GuiConsoleMainMenuItems);
|
||||||
DrawMenuBar(hWnd);
|
DrawMenuBar(hWnd);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID
|
static VOID
|
||||||
|
@ -597,6 +599,7 @@ OnNcCreate(HWND hWnd, LPCREATESTRUCTW Create)
|
||||||
Console = GuiData->Console;
|
Console = GuiData->Console;
|
||||||
|
|
||||||
GuiData->hWindow = hWnd;
|
GuiData->hWindow = hWnd;
|
||||||
|
GuiData->hSysMenu = GetSystemMenu(hWnd, FALSE);
|
||||||
|
|
||||||
/* Initialize the fonts */
|
/* Initialize the fonts */
|
||||||
if (!InitFonts(GuiData,
|
if (!InitFonts(GuiData,
|
||||||
|
@ -1370,6 +1373,7 @@ OnNcDestroy(HWND hWnd)
|
||||||
/* Free the GuiData registration */
|
/* Free the GuiData registration */
|
||||||
SetWindowLongPtrW(hWnd, GWLP_USERDATA, (DWORD_PTR)NULL);
|
SetWindowLongPtrW(hWnd, GWLP_USERDATA, (DWORD_PTR)NULL);
|
||||||
|
|
||||||
|
/* Reset the system menu back to default and destroy the previous menu */
|
||||||
GetSystemMenu(hWnd, TRUE);
|
GetSystemMenu(hWnd, TRUE);
|
||||||
|
|
||||||
if (GuiData)
|
if (GuiData)
|
||||||
|
|
|
@ -73,6 +73,7 @@ typedef struct _GUI_CONSOLE_DATA
|
||||||
|
|
||||||
BOOL HackCORE8394IgnoreNextMove; /* HACK FOR CORE-8394. See conwnd.c!OnMouse for more details. */
|
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 */
|
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 CmdIdLow ; /* Lowest menu id of the user-reserved menu id range */
|
||||||
UINT CmdIdHigh; /* Highest 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 *
|
* GUI Terminal Initialization *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
|
// FIXME: HACK: Potential HACK for CORE-8129; see revision 63595.
|
||||||
VOID
|
VOID
|
||||||
CreateSysMenu(HWND hWnd);
|
CreateSysMenu(HWND hWnd);
|
||||||
|
|
||||||
|
@ -1116,7 +1117,7 @@ GuiMenuControl(IN OUT PFRONTEND This,
|
||||||
GuiData->CmdIdLow = CmdIdLow ;
|
GuiData->CmdIdLow = CmdIdLow ;
|
||||||
GuiData->CmdIdHigh = CmdIdHigh;
|
GuiData->CmdIdHigh = CmdIdHigh;
|
||||||
|
|
||||||
return GetSystemMenu(GuiData->hWindow, FALSE);
|
return GuiData->hSysMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL NTAPI
|
static BOOL NTAPI
|
||||||
|
@ -1130,12 +1131,11 @@ GuiSetMenuClose(IN OUT PFRONTEND This,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
PGUI_CONSOLE_DATA GuiData = This->Context;
|
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;
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue