notepad: Use the explicit SendMessageW form.

This commit is contained in:
Michael Stefaniuc 2009-05-05 12:18:43 +02:00 committed by Alexandre Julliard
parent df5d82dd5b
commit 0c702d140c
2 changed files with 34 additions and 34 deletions

View File

@ -160,7 +160,7 @@ static VOID DoSaveFile(VOID)
if (!WriteFile(hFile, pTemp, size, &dwNumWrite, NULL))
ShowLastError();
else
SendMessage(Globals.hEdit, EM_SETMODIFY, FALSE, 0);
SendMessageW(Globals.hEdit, EM_SETMODIFY, FALSE, 0);
SetEndOfFile(hFile);
CloseHandle(hFile);
@ -177,7 +177,7 @@ BOOL DoCloseFile(void)
int nResult;
static const WCHAR empty_strW[] = { 0 };
if (SendMessage(Globals.hEdit, EM_GETMODIFY, 0, 0))
if (SendMessageW(Globals.hEdit, EM_GETMODIFY, 0, 0))
{
/* prompt user to save changes */
nResult = AlertFileNotSaved(Globals.szFileName);
@ -255,18 +255,18 @@ void DoOpenFile(LPCWSTR szFileName)
HeapFree(GetProcessHeap(), 0, pTemp);
SendMessage(Globals.hEdit, EM_SETMODIFY, FALSE, 0);
SendMessage(Globals.hEdit, EM_EMPTYUNDOBUFFER, 0, 0);
SendMessageW(Globals.hEdit, EM_SETMODIFY, FALSE, 0);
SendMessageW(Globals.hEdit, EM_EMPTYUNDOBUFFER, 0, 0);
SetFocus(Globals.hEdit);
/* If the file starts with .LOG, add a time/date at the end and set cursor after */
if (GetWindowTextW(Globals.hEdit, log, sizeof(log)/sizeof(log[0])) && !lstrcmp(log, dotlog))
{
static const WCHAR lfW[] = { '\r','\n',0 };
SendMessage(Globals.hEdit, EM_SETSEL, GetWindowTextLength(Globals.hEdit), -1);
SendMessage(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)lfW);
SendMessageW(Globals.hEdit, EM_SETSEL, GetWindowTextLength(Globals.hEdit), -1);
SendMessageW(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)lfW);
DIALOG_EditTimeDate();
SendMessage(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)lfW);
SendMessageW(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)lfW);
}
SetFileName(szFileName);
@ -280,7 +280,7 @@ VOID DIALOG_FileNew(VOID)
/* Close any files and prompt to save changes */
if (DoCloseFile()) {
SetWindowText(Globals.hEdit, empty_strW);
SendMessage(Globals.hEdit, EM_EMPTYUNDOBUFFER, 0, 0);
SendMessageW(Globals.hEdit, EM_EMPTYUNDOBUFFER, 0, 0);
SetFocus(Globals.hEdit);
}
}
@ -618,32 +618,32 @@ VOID DIALOG_FileExit(VOID)
VOID DIALOG_EditUndo(VOID)
{
SendMessage(Globals.hEdit, EM_UNDO, 0, 0);
SendMessageW(Globals.hEdit, EM_UNDO, 0, 0);
}
VOID DIALOG_EditCut(VOID)
{
SendMessage(Globals.hEdit, WM_CUT, 0, 0);
SendMessageW(Globals.hEdit, WM_CUT, 0, 0);
}
VOID DIALOG_EditCopy(VOID)
{
SendMessage(Globals.hEdit, WM_COPY, 0, 0);
SendMessageW(Globals.hEdit, WM_COPY, 0, 0);
}
VOID DIALOG_EditPaste(VOID)
{
SendMessage(Globals.hEdit, WM_PASTE, 0, 0);
SendMessageW(Globals.hEdit, WM_PASTE, 0, 0);
}
VOID DIALOG_EditDelete(VOID)
{
SendMessage(Globals.hEdit, WM_CLEAR, 0, 0);
SendMessageW(Globals.hEdit, WM_CLEAR, 0, 0);
}
VOID DIALOG_EditSelectAll(VOID)
{
SendMessage(Globals.hEdit, EM_SETSEL, 0, (LPARAM)-1);
SendMessageW(Globals.hEdit, EM_SETSEL, 0, -1);
}
VOID DIALOG_EditTimeDate(VOID)
@ -655,12 +655,12 @@ VOID DIALOG_EditTimeDate(VOID)
GetLocalTime(&st);
GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, szDate, MAX_STRING_LEN);
SendMessage(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)szDate);
SendMessageW(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)szDate);
SendMessage(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)spaceW);
SendMessageW(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)spaceW);
GetDateFormat(LOCALE_USER_DEFAULT, 0, &st, NULL, szDate, MAX_STRING_LEN);
SendMessage(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)szDate);
SendMessageW(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)szDate);
}
VOID DIALOG_EditWrap(VOID)
@ -681,16 +681,16 @@ VOID DIALOG_EditWrap(VOID)
return;
}
GetWindowText(Globals.hEdit, pTemp, size);
modify = SendMessage(Globals.hEdit, EM_GETMODIFY, 0, 0);
modify = SendMessageW(Globals.hEdit, EM_GETMODIFY, 0, 0);
DestroyWindow(Globals.hEdit);
GetClientRect(Globals.hMainWnd, &rc);
if( Globals.bWrapLongLines ) dwStyle |= WS_HSCROLL | ES_AUTOHSCROLL;
Globals.hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, editW, NULL, dwStyle,
0, 0, rc.right, rc.bottom, Globals.hMainWnd,
NULL, Globals.hInstance, NULL);
SendMessage(Globals.hEdit, WM_SETFONT, (WPARAM)Globals.hFont, (LPARAM)FALSE);
SendMessageW(Globals.hEdit, WM_SETFONT, (WPARAM)Globals.hFont, FALSE);
SetWindowTextW(Globals.hEdit, pTemp);
SendMessage(Globals.hEdit, EM_SETMODIFY, (WPARAM)modify, 0);
SendMessageW(Globals.hEdit, EM_SETMODIFY, modify, 0);
SetFocus(Globals.hEdit);
HeapFree(GetProcessHeap(), 0, pTemp);
@ -716,7 +716,7 @@ VOID DIALOG_SelectFont(VOID)
Globals.hFont=CreateFontIndirect( &lf );
Globals.lfFont=lf;
SendMessage( Globals.hEdit, WM_SETFONT, (WPARAM)Globals.hFont, (LPARAM)TRUE );
SendMessageW( Globals.hEdit, WM_SETFONT, (WPARAM)Globals.hFont, TRUE );
if( currfont!=NULL )
DeleteObject( currfont );
}

View File

@ -343,10 +343,10 @@ static VOID NOTEPAD_InitMenuPopup(HMENU menu, int index)
int enable;
EnableMenuItem(menu, CMD_UNDO,
SendMessage(Globals.hEdit, EM_CANUNDO, 0, 0) ? MF_ENABLED : MF_GRAYED);
SendMessageW(Globals.hEdit, EM_CANUNDO, 0, 0) ? MF_ENABLED : MF_GRAYED);
EnableMenuItem(menu, CMD_PASTE,
IsClipboardFormatAvailable(CF_TEXT) ? MF_ENABLED : MF_GRAYED);
enable = SendMessage(Globals.hEdit, EM_GETSEL, 0, 0);
enable = SendMessageW(Globals.hEdit, EM_GETSEL, 0, 0);
enable = (HIWORD(enable) == LOWORD(enable)) ? MF_GRAYED : MF_ENABLED;
EnableMenuItem(menu, CMD_CUT, enable);
EnableMenuItem(menu, CMD_COPY, enable);
@ -385,7 +385,7 @@ void NOTEPAD_DoFind(FINDREPLACE *fr)
if (!content) return;
GetWindowText(Globals.hEdit, content, fileLen);
SendMessage(Globals.hEdit, EM_GETSEL, 0, (LPARAM)&pos);
SendMessageW(Globals.hEdit, EM_GETSEL, 0, (LPARAM)&pos);
switch (fr->Flags & (FR_DOWN|FR_MATCHCASE))
{
case 0:
@ -412,7 +412,7 @@ void NOTEPAD_DoFind(FINDREPLACE *fr)
return;
}
SendMessage(Globals.hEdit, EM_SETSEL, found - content, found - content + len);
SendMessageW(Globals.hEdit, EM_SETSEL, found - content, found - content + len);
}
void NOTEPAD_DoReplace(FINDREPLACE *fr)
@ -428,16 +428,16 @@ void NOTEPAD_DoReplace(FINDREPLACE *fr)
if (!content) return;
GetWindowText(Globals.hEdit, content, fileLen);
SendMessage(Globals.hEdit, EM_GETSEL, (WPARAM)&pos_start, (LPARAM)&pos);
SendMessageW(Globals.hEdit, EM_GETSEL, (WPARAM)&pos_start, (LPARAM)&pos);
switch (fr->Flags & (FR_DOWN|FR_MATCHCASE))
{
case FR_DOWN:
if ( pos-pos_start == len && StrCmpNI(fr->lpstrFindWhat, content+pos_start, len) == 0)
SendMessage(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)fr->lpstrReplaceWith);
SendMessageW(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)fr->lpstrReplaceWith);
break;
case FR_DOWN|FR_MATCHCASE:
if ( pos-pos_start == len && StrCmpN(fr->lpstrFindWhat, content+pos_start, len) == 0)
SendMessage(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)fr->lpstrReplaceWith);
SendMessageW(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)fr->lpstrReplaceWith);
break;
default: /* shouldn't happen */
return;
@ -455,14 +455,14 @@ void NOTEPAD_DoReplaceAll(FINDREPLACE *fr)
int fileLen;
DWORD pos;
SendMessage(Globals.hEdit, EM_SETSEL, 0, 0);
SendMessageW(Globals.hEdit, EM_SETSEL, 0, 0);
while(TRUE){
fileLen = GetWindowTextLength(Globals.hEdit) + 1;
content = HeapAlloc(GetProcessHeap(), 0, fileLen * sizeof(TCHAR));
if (!content) return;
GetWindowText(Globals.hEdit, content, fileLen);
SendMessage(Globals.hEdit, EM_GETSEL, 0, (LPARAM)&pos);
SendMessageW(Globals.hEdit, EM_GETSEL, 0, (LPARAM)&pos);
switch (fr->Flags & (FR_DOWN|FR_MATCHCASE))
{
case FR_DOWN:
@ -478,11 +478,11 @@ void NOTEPAD_DoReplaceAll(FINDREPLACE *fr)
if(found == NULL)
{
SendMessage(Globals.hEdit, EM_SETSEL, 0, 0);
SendMessageW(Globals.hEdit, EM_SETSEL, 0, 0);
return;
}
SendMessage(Globals.hEdit, EM_SETSEL, found - content, found - content + len);
SendMessage(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)fr->lpstrReplaceWith);
SendMessageW(Globals.hEdit, EM_SETSEL, found - content, found - content + len);
SendMessageW(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)fr->lpstrReplaceWith);
}
}
@ -535,7 +535,7 @@ static LRESULT WINAPI NOTEPAD_WndProc(HWND hWnd, UINT msg, WPARAM wParam,
NULL, Globals.hInstance, NULL);
Globals.hFont = CreateFontIndirect(&Globals.lfFont);
SendMessage(Globals.hEdit, WM_SETFONT, (WPARAM)Globals.hFont, (LPARAM)FALSE);
SendMessageW(Globals.hEdit, WM_SETFONT, (WPARAM)Globals.hFont, FALSE);
break;
}