Commit e173504c authored by Alexander Nicolaysen Sørnes's avatar Alexander Nicolaysen Sørnes Committed by Alexandre Julliard

wordpad: Split code into set_caption function.

parent 360dee62
...@@ -114,7 +114,24 @@ static DWORD CALLBACK stream_in(DWORD_PTR cookie, LPBYTE buffer, LONG cb, LONG * ...@@ -114,7 +114,24 @@ static DWORD CALLBACK stream_in(DWORD_PTR cookie, LPBYTE buffer, LONG cb, LONG *
return 0; return 0;
} }
static void DoOpenFile(LPCWSTR szFileName) static void set_caption(LPCWSTR wszNewFileName)
{
static const WCHAR wszSeparator[] = {' ','-',' ','\0'};
WCHAR wszCaption[MAX_PATH];
if(wszNewFileName)
{
lstrcpyW(wszCaption, wszNewFileName);
lstrcatW(wszCaption, wszSeparator);
lstrcatW(wszCaption, wszAppTitle);
SetWindowTextW(hMainWnd, wszCaption);
} else
{
SetWindowTextW(hMainWnd, wszAppTitle);
}
}
static void DoOpenFile(LPCWSTR szOpenFileName)
{ {
HANDLE hFile; HANDLE hFile;
LPSTR pTemp; LPSTR pTemp;
...@@ -122,11 +139,7 @@ static void DoOpenFile(LPCWSTR szFileName) ...@@ -122,11 +139,7 @@ static void DoOpenFile(LPCWSTR szFileName)
DWORD dwNumRead; DWORD dwNumRead;
EDITSTREAM es; EDITSTREAM es;
char szCaption[MAX_PATH]; hFile = CreateFileW(szOpenFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
char szAppTitle[sizeof(wszAppTitle)];
char szSeparator[] = " - ";
hFile = CreateFileW(szFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE) if (hFile == INVALID_HANDLE_VALUE)
return; return;
...@@ -166,14 +179,7 @@ static void DoOpenFile(LPCWSTR szFileName) ...@@ -166,14 +179,7 @@ static void DoOpenFile(LPCWSTR szFileName)
SetFocus(hEditorWnd); SetFocus(hEditorWnd);
WideCharToMultiByte(CP_ACP, 0, wszAppTitle, -1, szAppTitle, sizeof(wszAppTitle), NULL, NULL); set_caption(szOpenFileName);
WideCharToMultiByte(CP_ACP, 0, szFileName, -1, szCaption, MAX_PATH, NULL, NULL);
lstrcat(szCaption, szSeparator);
lstrcat(szCaption, szAppTitle);
SetWindowText(hMainWnd, szCaption);
} }
static void DialogOpenFile(void) static void DialogOpenFile(void)
...@@ -435,7 +441,7 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam) ...@@ -435,7 +441,7 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam)
case ID_FILE_NEW: case ID_FILE_NEW:
SetWindowTextA(hwndEditor, ""); SetWindowTextA(hwndEditor, "");
SetWindowTextW(hMainWnd, wszAppTitle); set_caption(NULL);
/* FIXME: set default format too */ /* FIXME: set default format too */
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment