mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 16:52:59 +00:00
[NTVDM]
Usability fixes (part 2): - Properly keep the mouse show state across screenbuffer switches. - Use unicode strings for the disk menu items. See r69428. svn path=/trunk/; revision=69431
This commit is contained in:
parent
9fef17180f
commit
cf07fbe7ba
3 changed files with 66 additions and 60 deletions
|
@ -961,12 +961,9 @@ static VOID VgaSetActiveScreenBuffer(HANDLE ScreenBuffer)
|
||||||
{
|
{
|
||||||
ASSERT(ScreenBuffer);
|
ASSERT(ScreenBuffer);
|
||||||
|
|
||||||
/* Set the active buffer */
|
/* Set the active buffer and reattach the VDM UI to it */
|
||||||
SetConsoleActiveScreenBuffer(ScreenBuffer);
|
SetConsoleActiveScreenBuffer(ScreenBuffer);
|
||||||
|
ConsoleReattach(ScreenBuffer);
|
||||||
/* Reinitialize the VDM menu */
|
|
||||||
DestroyVdmMenu();
|
|
||||||
CreateVdmMenu(ScreenBuffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL VgaEnterGraphicsMode(PCOORD Resolution)
|
static BOOL VgaEnterGraphicsMode(PCOORD Resolution)
|
||||||
|
|
|
@ -163,19 +163,20 @@ UpdateVdmMenuMouse(VOID)
|
||||||
UpdateVdmMenuDisks(VOID)
|
UpdateVdmMenuDisks(VOID)
|
||||||
{
|
{
|
||||||
UINT_PTR ItemID;
|
UINT_PTR ItemID;
|
||||||
|
UNICODE_STRING ValueString;
|
||||||
USHORT i;
|
USHORT i;
|
||||||
|
|
||||||
CHAR szNoMedia[100];
|
WCHAR szNoMedia[100];
|
||||||
CHAR szMenuString1[256], szMenuString2[256];
|
WCHAR szMenuString1[256], szMenuString2[256];
|
||||||
|
|
||||||
/* Update the disks menu items */
|
/* Update the disks menu items */
|
||||||
|
|
||||||
LoadStringA(GetModuleHandle(NULL),
|
LoadStringW(GetModuleHandle(NULL),
|
||||||
IDS_NO_MEDIA,
|
IDS_NO_MEDIA,
|
||||||
szNoMedia,
|
szNoMedia,
|
||||||
ARRAYSIZE(szNoMedia));
|
ARRAYSIZE(szNoMedia));
|
||||||
|
|
||||||
LoadStringA(GetModuleHandle(NULL),
|
LoadStringW(GetModuleHandle(NULL),
|
||||||
IDS_VDM_MOUNT_FLOPPY,
|
IDS_VDM_MOUNT_FLOPPY,
|
||||||
szMenuString1,
|
szMenuString1,
|
||||||
ARRAYSIZE(szMenuString1));
|
ARRAYSIZE(szMenuString1));
|
||||||
|
@ -188,10 +189,15 @@ UpdateVdmMenuDisks(VOID)
|
||||||
GlobalSettings.FloppyDisks[i].Buffer &&
|
GlobalSettings.FloppyDisks[i].Buffer &&
|
||||||
GlobalSettings.FloppyDisks[i].Buffer != '\0')
|
GlobalSettings.FloppyDisks[i].Buffer != '\0')
|
||||||
{
|
{
|
||||||
|
/* Convert the ANSI string to UNICODE */
|
||||||
|
RtlAnsiStringToUnicodeString(&ValueString, &GlobalSettings.FloppyDisks[i], TRUE);
|
||||||
|
|
||||||
/* Update item text */
|
/* Update item text */
|
||||||
_snprintf(szMenuString2, ARRAYSIZE(szMenuString2), szMenuString1, i, GlobalSettings.FloppyDisks[i].Buffer);
|
_snwprintf(szMenuString2, ARRAYSIZE(szMenuString2), szMenuString1, i, ValueString.Buffer);
|
||||||
szMenuString2[ARRAYSIZE(szMenuString2) - 1] = ANSI_NULL;
|
szMenuString2[ARRAYSIZE(szMenuString2) - 1] = UNICODE_NULL;
|
||||||
ModifyMenuA(hConsoleMenu, ItemID, MF_BYCOMMAND | MF_STRING, ItemID, szMenuString2);
|
ModifyMenuW(hConsoleMenu, ItemID, MF_BYCOMMAND | MF_STRING, ItemID, szMenuString2);
|
||||||
|
|
||||||
|
RtlFreeUnicodeString(&ValueString);
|
||||||
|
|
||||||
/* Enable the eject item */
|
/* Enable the eject item */
|
||||||
EnableMenuItem(hConsoleMenu, ItemID + 1, MF_BYCOMMAND | MF_ENABLED);
|
EnableMenuItem(hConsoleMenu, ItemID + 1, MF_BYCOMMAND | MF_ENABLED);
|
||||||
|
@ -199,9 +205,9 @@ UpdateVdmMenuDisks(VOID)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Update item text */
|
/* Update item text */
|
||||||
_snprintf(szMenuString2, ARRAYSIZE(szMenuString2), szMenuString1, i, szNoMedia);
|
_snwprintf(szMenuString2, ARRAYSIZE(szMenuString2), szMenuString1, i, szNoMedia);
|
||||||
szMenuString2[ARRAYSIZE(szMenuString2) - 1] = ANSI_NULL;
|
szMenuString2[ARRAYSIZE(szMenuString2) - 1] = UNICODE_NULL;
|
||||||
ModifyMenuA(hConsoleMenu, ItemID, MF_BYCOMMAND | MF_STRING, ItemID, szMenuString2);
|
ModifyMenuW(hConsoleMenu, ItemID, MF_BYCOMMAND | MF_STRING, ItemID, szMenuString2);
|
||||||
|
|
||||||
/* Disable the eject item */
|
/* Disable the eject item */
|
||||||
EnableMenuItem(hConsoleMenu, ItemID + 1, MF_BYCOMMAND | MF_GRAYED);
|
EnableMenuItem(hConsoleMenu, ItemID + 1, MF_BYCOMMAND | MF_GRAYED);
|
||||||
|
@ -209,47 +215,28 @@ UpdateVdmMenuDisks(VOID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID ShowHideMousePointer(HANDLE ConOutHandle, BOOLEAN ShowPtr)
|
|
||||||
{
|
|
||||||
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) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static VOID
|
static VOID
|
||||||
UpdateVdmMenu(VOID)
|
UpdateVdmMenu(VOID)
|
||||||
{
|
{
|
||||||
// This is a temporary HACK until I find the most elegant way
|
|
||||||
// to synchronize mouse cursor display with console screenbuffer switches.
|
|
||||||
ShowHideMousePointer(CurrentConsoleOutput, ShowPointer);
|
|
||||||
|
|
||||||
UpdateVdmMenuMouse();
|
UpdateVdmMenuMouse();
|
||||||
UpdateVdmMenuDisks();
|
UpdateVdmMenuDisks();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*static*/ VOID
|
static VOID
|
||||||
CreateVdmMenu(HANDLE ConOutHandle)
|
CreateVdmMenu(HANDLE ConOutHandle)
|
||||||
{
|
{
|
||||||
HMENU hVdmSubMenu;
|
HMENU hVdmSubMenu;
|
||||||
UINT_PTR ItemID = ID_VDM_DRIVES;
|
UINT_PTR ItemID;
|
||||||
UINT Pos;
|
UINT Pos;
|
||||||
|
USHORT i;
|
||||||
WCHAR szNoMedia[100];
|
WCHAR szNoMedia[100];
|
||||||
WCHAR szMenuString1[256], szMenuString2[256];
|
WCHAR szMenuString1[256], szMenuString2[256];
|
||||||
|
|
||||||
hConsoleMenu = ConsoleMenuControl(ConOutHandle,
|
hConsoleMenu = ConsoleMenuControl(ConOutHandle,
|
||||||
ID_SHOWHIDE_MOUSE,
|
ID_SHOWHIDE_MOUSE,
|
||||||
ID_VDM_DRIVES + 4);
|
ID_VDM_DRIVES + (2 * ARRAYSIZE(GlobalSettings.FloppyDisks)));
|
||||||
if (hConsoleMenu == NULL) return;
|
if (hConsoleMenu == NULL) return;
|
||||||
|
|
||||||
CurrentConsoleOutput = ConOutHandle;
|
|
||||||
|
|
||||||
/* Get the position where we are going to insert our menu items */
|
/* Get the position where we are going to insert our menu items */
|
||||||
VdmMenuPos = GetMenuItemCount(hConsoleMenu);
|
VdmMenuPos = GetMenuItemCount(hConsoleMenu);
|
||||||
|
|
||||||
|
@ -273,30 +260,32 @@ CreateVdmMenu(HANDLE ConOutHandle)
|
||||||
szMenuString1,
|
szMenuString1,
|
||||||
ARRAYSIZE(szMenuString1));
|
ARRAYSIZE(szMenuString1));
|
||||||
|
|
||||||
/* Drive 0 -- Mount */
|
/* Drive 'x' -- Mount */
|
||||||
_snwprintf(szMenuString2, ARRAYSIZE(szMenuString2), szMenuString1, 0, szNoMedia);
|
for (i = 0; i < ARRAYSIZE(GlobalSettings.FloppyDisks); ++i)
|
||||||
szMenuString2[ARRAYSIZE(szMenuString2) - 1] = UNICODE_NULL;
|
{
|
||||||
InsertMenuW(hVdmSubMenu, Pos++, MF_STRING | MF_BYPOSITION, ItemID + 0, szMenuString2);
|
ItemID = ID_VDM_DRIVES + (2 * i);
|
||||||
|
|
||||||
/* Drive 1 -- Mount */
|
/* Add the item */
|
||||||
_snwprintf(szMenuString2, ARRAYSIZE(szMenuString2), szMenuString1, 1, szNoMedia);
|
_snwprintf(szMenuString2, ARRAYSIZE(szMenuString2), szMenuString1, i, szNoMedia);
|
||||||
szMenuString2[ARRAYSIZE(szMenuString2) - 1] = UNICODE_NULL;
|
szMenuString2[ARRAYSIZE(szMenuString2) - 1] = UNICODE_NULL;
|
||||||
InsertMenuW(hVdmSubMenu, Pos++, MF_STRING | MF_BYPOSITION, ItemID + 2, szMenuString2);
|
InsertMenuW(hVdmSubMenu, Pos++, MF_STRING | MF_BYPOSITION, ItemID, szMenuString2);
|
||||||
|
}
|
||||||
|
|
||||||
LoadStringW(GetModuleHandle(NULL),
|
LoadStringW(GetModuleHandle(NULL),
|
||||||
IDS_VDM_EJECT_FLOPPY,
|
IDS_VDM_EJECT_FLOPPY,
|
||||||
szMenuString1,
|
szMenuString1,
|
||||||
ARRAYSIZE(szMenuString1));
|
ARRAYSIZE(szMenuString1));
|
||||||
|
|
||||||
/* Drive 0 -- Eject */
|
/* Drive 'x' -- Eject */
|
||||||
_snwprintf(szMenuString2, ARRAYSIZE(szMenuString2), szMenuString1, 0);
|
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;
|
szMenuString2[ARRAYSIZE(szMenuString2) - 1] = UNICODE_NULL;
|
||||||
InsertMenuW(hVdmSubMenu, Pos++, MF_STRING | MF_BYPOSITION, ItemID + 1, szMenuString2);
|
InsertMenuW(hVdmSubMenu, Pos++, MF_STRING | MF_BYPOSITION, ItemID + 1, szMenuString2);
|
||||||
|
}
|
||||||
/* Drive 1 -- Eject */
|
|
||||||
_snwprintf(szMenuString2, ARRAYSIZE(szMenuString2), szMenuString1, 1);
|
|
||||||
szMenuString2[ARRAYSIZE(szMenuString2) - 1] = UNICODE_NULL;
|
|
||||||
InsertMenuW(hVdmSubMenu, Pos++, MF_STRING | MF_BYPOSITION, ItemID + 3, szMenuString2);
|
|
||||||
|
|
||||||
/* Refresh the menu state */
|
/* Refresh the menu state */
|
||||||
UpdateVdmMenu();
|
UpdateVdmMenu();
|
||||||
|
@ -304,7 +293,7 @@ CreateVdmMenu(HANDLE ConOutHandle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*static*/ VOID
|
static VOID
|
||||||
DestroyVdmMenu(VOID)
|
DestroyVdmMenu(VOID)
|
||||||
{
|
{
|
||||||
UINT i = 0;
|
UINT i = 0;
|
||||||
|
@ -317,8 +306,20 @@ DestroyVdmMenu(VOID)
|
||||||
} while (!(Items[i].uID == 0 && Items[i].SubMenu == NULL && Items[i].uCmdID == 0));
|
} while (!(Items[i].uID == 0 && Items[i].SubMenu == NULL && Items[i].uCmdID == 0));
|
||||||
|
|
||||||
DrawMenuBar(hConsoleWnd);
|
DrawMenuBar(hConsoleWnd);
|
||||||
|
}
|
||||||
|
|
||||||
CurrentConsoleOutput = INVALID_HANDLE_VALUE;
|
static VOID ShowHideMousePointer(HANDLE ConOutHandle, BOOLEAN ShowPtr)
|
||||||
|
{
|
||||||
|
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) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID EnableExtraHardware(HANDLE ConsoleInput)
|
static VOID EnableExtraHardware(HANDLE ConsoleInput)
|
||||||
|
@ -867,6 +868,17 @@ ConsoleDetach(VOID)
|
||||||
SetConsoleMode(ConsoleInput , OrgConsoleInputMode );
|
SetConsoleMode(ConsoleInput , OrgConsoleInputMode );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
ConsoleReattach(HANDLE ConOutHandle)
|
||||||
|
{
|
||||||
|
DestroyVdmMenu();
|
||||||
|
CurrentConsoleOutput = ConOutHandle;
|
||||||
|
CreateVdmMenu(ConOutHandle);
|
||||||
|
|
||||||
|
/* Synchronize mouse cursor display with console screenbuffer switches */
|
||||||
|
ShowHideMousePointer(CurrentConsoleOutput, ShowPointer);
|
||||||
|
}
|
||||||
|
|
||||||
static BOOL
|
static BOOL
|
||||||
ConsoleInit(VOID)
|
ConsoleInit(VOID)
|
||||||
{
|
{
|
||||||
|
|
|
@ -99,15 +99,12 @@ VOID DisplayMessage(IN LPCWSTR Format, ...);
|
||||||
VOID PrintMessageAnsi(IN CHAR_PRINT CharPrint,
|
VOID PrintMessageAnsi(IN CHAR_PRINT CharPrint,
|
||||||
IN LPCSTR Format, ...);
|
IN LPCSTR Format, ...);
|
||||||
|
|
||||||
/*static*/ VOID
|
|
||||||
CreateVdmMenu(HANDLE ConOutHandle);
|
|
||||||
/*static*/ VOID
|
|
||||||
DestroyVdmMenu(VOID);
|
|
||||||
/*static*/ VOID
|
/*static*/ VOID
|
||||||
UpdateVdmMenuDisks(VOID);
|
UpdateVdmMenuDisks(VOID);
|
||||||
|
|
||||||
BOOL ConsoleAttach(VOID);
|
BOOL ConsoleAttach(VOID);
|
||||||
VOID ConsoleDetach(VOID);
|
VOID ConsoleDetach(VOID);
|
||||||
|
VOID ConsoleReattach(HANDLE ConOutHandle);
|
||||||
VOID MenuEventHandler(PMENU_EVENT_RECORD MenuEvent);
|
VOID MenuEventHandler(PMENU_EVENT_RECORD MenuEvent);
|
||||||
VOID FocusEventHandler(PFOCUS_EVENT_RECORD FocusEvent);
|
VOID FocusEventHandler(PFOCUS_EVENT_RECORD FocusEvent);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue