wordpad: Clean up font effects toggling code.

This commit is contained in:
Alexander Nicolaysen Sørnes 2007-09-08 20:23:26 +02:00 committed by Alexandre Julliard
parent 0397146d72
commit 8710108b24
1 changed files with 16 additions and 8 deletions

View File

@ -2798,18 +2798,26 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam)
case ID_FORMAT_UNDERLINE:
{
CHARFORMAT2W fmt;
int mask = CFM_BOLD;
if (LOWORD(wParam) == ID_FORMAT_ITALIC) mask = CFM_ITALIC;
if (LOWORD(wParam) == ID_FORMAT_UNDERLINE) mask = CFM_UNDERLINE;
int effects = CFE_BOLD;
ZeroMemory(&fmt, sizeof(fmt));
fmt.cbSize = sizeof(fmt);
SendMessageW(hwndEditor, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&fmt);
if (!(fmt.dwMask&mask))
fmt.dwEffects |= mask;
else
fmt.dwEffects ^= mask;
fmt.dwMask = mask;
fmt.dwMask = CFM_BOLD;
if (LOWORD(wParam) == ID_FORMAT_ITALIC)
{
effects = CFE_ITALIC;
fmt.dwMask = CFM_ITALIC;
} else if (LOWORD(wParam) == ID_FORMAT_UNDERLINE)
{
effects = CFE_UNDERLINE;
fmt.dwMask = CFM_UNDERLINE;
}
fmt.dwEffects ^= effects;
SendMessageW(hwndEditor, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&fmt);
break;
}