Convert title from UNICODE_STRING to nul-terminated

svn path=/trunk/; revision=17761
This commit is contained in:
Gé van Geldorp 2005-09-09 11:43:26 +00:00
parent b1e0054bee
commit c0337d5d24

View file

@ -786,6 +786,7 @@ GuiConsoleNotifyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
HWND NewWindow; HWND NewWindow;
LONG WindowCount; LONG WindowCount;
MSG Msg; MSG Msg;
PWCHAR Buffer, Title;
PCSRSS_CONSOLE Console = (PCSRSS_CONSOLE) lParam; PCSRSS_CONSOLE Console = (PCSRSS_CONSOLE) lParam;
switch(msg) switch(msg)
@ -794,8 +795,20 @@ GuiConsoleNotifyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
SetWindowLongW(hWnd, GWL_USERDATA, 0); SetWindowLongW(hWnd, GWL_USERDATA, 0);
return 0; return 0;
case PM_CREATE_CONSOLE: case PM_CREATE_CONSOLE:
Buffer = HeapAlloc(Win32CsrApiHeap, 0,
Console->Title.Length + sizeof(WCHAR));
if (NULL != Buffer)
{
memcpy(Buffer, Console->Title.Buffer, Console->Title.Length);
Buffer[Console->Title.Length / sizeof(WCHAR)] = L'\0';
Title = Buffer;
}
else
{
Title = L"";
}
NewWindow = CreateWindowW(L"ConsoleWindowClass", NewWindow = CreateWindowW(L"ConsoleWindowClass",
Console->Title.Buffer, Title,
WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
@ -805,6 +818,10 @@ GuiConsoleNotifyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
NULL, NULL,
(HINSTANCE) GetModuleHandleW(NULL), (HINSTANCE) GetModuleHandleW(NULL),
(PVOID) Console); (PVOID) Console);
if (NULL != Buffer)
{
HeapFree(Win32CsrApiHeap, 0, Buffer);
}
Console->hWindow = NewWindow; Console->hWindow = NewWindow;
if (NULL != NewWindow) if (NULL != NewWindow)
{ {
@ -934,7 +951,25 @@ GuiInitScreenBuffer(PCSRSS_CONSOLE Console, PCSRSS_SCREEN_BUFFER Buffer)
STATIC BOOL STDCALL STATIC BOOL STDCALL
GuiChangeTitle(PCSRSS_CONSOLE Console) GuiChangeTitle(PCSRSS_CONSOLE Console)
{ {
SendMessageW(Console->hWindow, WM_SETTEXT, 0, (LPARAM) Console->Title.Buffer); PWCHAR Buffer, Title;
Buffer = HeapAlloc(Win32CsrApiHeap, 0,
Console->Title.Length + sizeof(WCHAR));
if (NULL != Buffer)
{
memcpy(Buffer, Console->Title.Buffer, Console->Title.Length);
Buffer[Console->Title.Length / sizeof(WCHAR)] = L'\0';
Title = Buffer;
}
else
{
Title = L"";
}
SendMessageW(Console->hWindow, WM_SETTEXT, 0, (LPARAM) Title);
if (NULL != Buffer)
{
HeapFree(Win32CsrApiHeap, 0, Buffer);
}
return TRUE; return TRUE;
} }