wordpad: Clean up font effects toggling code.
This commit is contained in:
parent
0397146d72
commit
8710108b24
|
@ -2798,18 +2798,26 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||||
case ID_FORMAT_UNDERLINE:
|
case ID_FORMAT_UNDERLINE:
|
||||||
{
|
{
|
||||||
CHARFORMAT2W fmt;
|
CHARFORMAT2W fmt;
|
||||||
int mask = CFM_BOLD;
|
int effects = CFE_BOLD;
|
||||||
if (LOWORD(wParam) == ID_FORMAT_ITALIC) mask = CFM_ITALIC;
|
|
||||||
if (LOWORD(wParam) == ID_FORMAT_UNDERLINE) mask = CFM_UNDERLINE;
|
|
||||||
|
|
||||||
ZeroMemory(&fmt, sizeof(fmt));
|
ZeroMemory(&fmt, sizeof(fmt));
|
||||||
fmt.cbSize = sizeof(fmt);
|
fmt.cbSize = sizeof(fmt);
|
||||||
SendMessageW(hwndEditor, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&fmt);
|
SendMessageW(hwndEditor, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&fmt);
|
||||||
if (!(fmt.dwMask&mask))
|
|
||||||
fmt.dwEffects |= mask;
|
fmt.dwMask = CFM_BOLD;
|
||||||
else
|
|
||||||
fmt.dwEffects ^= mask;
|
if (LOWORD(wParam) == ID_FORMAT_ITALIC)
|
||||||
fmt.dwMask = mask;
|
{
|
||||||
|
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);
|
SendMessageW(hwndEditor, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&fmt);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue