📄 fontdlg.c
字号:
case cmb2:
case cmb3:
case cmb5:
if (HIWORD(wParam)==CBN_SELCHANGE || HIWORD(wParam)== BN_CLICKED )
{
WCHAR str[256];
WINDOWINFO wininfo;
TRACE("WM_COMMAND/cmb2,3 =%08lX\n", lParam);
i=SendDlgItemMessageW(hDlg,cmb1,CB_GETCURSEL,0,0);
if (i==CB_ERR)
i=GetDlgItemTextW( hDlg, cmb1, str, 256 );
else
{
SendDlgItemMessageW(hDlg,cmb1,CB_GETLBTEXT,i,
(LPARAM)str);
l=SendDlgItemMessageW(hDlg,cmb1,CB_GETITEMDATA,i,0);
lpcf->nFontType = LOWORD(l);
/* FIXME: lpcf->nFontType |= .... SIMULATED_FONTTYPE and so */
/* same value reported to the EnumFonts
call back with the extra FONTTYPE_... bits added */
lpxx->lfPitchAndFamily = HIWORD(l) >> 8;
}
lstrcpyW(lpxx->lfFaceName,str);
i=SendDlgItemMessageW(hDlg, cmb2, CB_GETCURSEL, 0, 0);
if (i!=CB_ERR)
{
l=SendDlgItemMessageW(hDlg, cmb2, CB_GETITEMDATA, i, 0);
if (0!=(lpxx->lfItalic=HIWORD(l)))
lpcf->nFontType |= ITALIC_FONTTYPE;
if ((lpxx->lfWeight=LOWORD(l)) > FW_MEDIUM)
lpcf->nFontType |= BOLD_FONTTYPE;
}
i=SendDlgItemMessageW(hDlg, cmb3, CB_GETCURSEL, 0, 0);
if( i != CB_ERR)
lpcf->iPointSize = 10 * LOWORD(SendDlgItemMessageW(hDlg, cmb3,
CB_GETITEMDATA , i, 0));
else
lpcf->iPointSize = 100;
hdc = CFn_GetDC(lpcf);
if( hdc)
{
lpxx->lfHeight = - MulDiv( lpcf->iPointSize ,
GetDeviceCaps(hdc, LOGPIXELSY), 720);
CFn_ReleaseDC(lpcf, hdc);
} else
lpxx->lfHeight = -lpcf->iPointSize / 10;
i=SendDlgItemMessageW(hDlg, cmb5, CB_GETCURSEL, 0, 0);
if (i!=CB_ERR)
lpxx->lfCharSet=SendDlgItemMessageW(hDlg, cmb5, CB_GETITEMDATA, i, 0);
else
lpxx->lfCharSet = DEFAULT_CHARSET;
lpxx->lfStrikeOut=IsDlgButtonChecked(hDlg,chx1);
lpxx->lfUnderline=IsDlgButtonChecked(hDlg,chx2);
lpxx->lfWidth=lpxx->lfOrientation=lpxx->lfEscapement=0;
lpxx->lfOutPrecision=OUT_DEFAULT_PRECIS;
lpxx->lfClipPrecision=CLIP_DEFAULT_PRECIS;
lpxx->lfQuality=DEFAULT_QUALITY;
wininfo.cbSize=sizeof(wininfo);
if( GetWindowInfo( GetDlgItem( hDlg, stc5), &wininfo ) )
{
MapWindowPoints( 0, hDlg, (LPPOINT) &wininfo.rcWindow, 2);
InvalidateRect( hDlg, &wininfo.rcWindow, TRUE );
}
}
break;
case cmb4:
i=SendDlgItemMessageW(hDlg, cmb4, CB_GETCURSEL, 0, 0);
if (i!=CB_ERR)
{
WINDOWINFO wininfo;
lpcf->rgbColors = SendDlgItemMessageW(hDlg, cmb4, CB_GETITEMDATA, i, 0);
wininfo.cbSize=sizeof(wininfo);
if( GetWindowInfo( GetDlgItem( hDlg, stc5), &wininfo ) )
{
MapWindowPoints( 0, hDlg, (LPPOINT) &wininfo.rcWindow, 2);
InvalidateRect( hDlg, &wininfo.rcWindow, TRUE );
}
}
break;
case psh15:
i=RegisterWindowMessageW( HELPMSGSTRINGW );
if (lpcf->hwndOwner)
SendMessageW(lpcf->hwndOwner, i, 0, (LPARAM)GetPropW(hDlg, strWineFontData));
/* if (CFn_HookCallChk(lpcf))
CallWindowProc16(lpcf->lpfnHook,hDlg,WM_COMMAND,psh15,(LPARAM)lpcf);*/
break;
case IDOK:
if ( (!(lpcf->Flags & CF_LIMITSIZE)) ||
( (lpcf->Flags & CF_LIMITSIZE) &&
(lpcf->iPointSize >= 10 * lpcf->nSizeMin) &&
(lpcf->iPointSize <= 10 * lpcf->nSizeMax)))
EndDialog(hDlg, TRUE);
else
{
WCHAR buffer[80];
WCHAR format[80];
LoadStringW(COMDLG32_hInstance, IDS_FONT_SIZE, format, sizeof(format)/sizeof(WCHAR));
wsprintfW(buffer, format, lpcf->nSizeMin,lpcf->nSizeMax);
MessageBoxW(hDlg, buffer, NULL, MB_OK);
}
return(TRUE);
case IDCANCEL:
EndDialog(hDlg, FALSE);
return(TRUE);
}
return(FALSE);
}
static LRESULT CFn_WMDestroy(HWND hwnd, WPARAM wParam, LPARAM lParam, LPCHOOSEFONTW lpcfw)
{
LPCHOOSEFONTA lpcfa;
LPSTR lpszStyle;
LPLOGFONTA lpLogFonta;
int len;
lpcfa = GetPropW(hwnd, strWineFontData_a);
lpLogFonta = lpcfa->lpLogFont;
lpszStyle = lpcfa->lpszStyle;
memcpy(lpcfa, lpcfw, sizeof(CHOOSEFONTA));
lpcfa->lpLogFont = lpLogFonta;
lpcfa->lpszStyle = lpszStyle;
memcpy(lpcfa->lpLogFont, lpcfw->lpLogFont, sizeof(LOGFONTA));
WideCharToMultiByte(CP_ACP, 0, lpcfw->lpLogFont->lfFaceName,
LF_FACESIZE, lpcfa->lpLogFont->lfFaceName, LF_FACESIZE, 0, 0);
if((lpcfw->Flags & CF_USESTYLE) && lpcfw->lpszStyle) {
len = WideCharToMultiByte(CP_ACP, 0, lpcfw->lpszStyle, -1, NULL, -1, 0, 0);
WideCharToMultiByte(CP_ACP, 0, lpcfw->lpszStyle, -1, lpcfa->lpszStyle, len, 0, 0);
HeapFree(GetProcessHeap(), 0, lpcfw->lpszStyle);
}
HeapFree(GetProcessHeap(), 0, lpcfw->lpLogFont);
HeapFree(GetProcessHeap(), 0, lpcfw);
SetPropW(hwnd, strWineFontData, 0);
return TRUE;
}
LRESULT CFn_WMPaint(HWND hDlg, WPARAM wParam, LPARAM lParam, const CHOOSEFONTW *lpcf)
{
WINDOWINFO info;
info.cbSize=sizeof(info);
if( GetWindowInfo( GetDlgItem( hDlg, stc5), &info ) )
{
PAINTSTRUCT ps;
HDC hdc;
HPEN hOrigPen;
HFONT hOrigFont;
LOGFONTW lf = *(lpcf->lpLogFont);
MapWindowPoints( 0, hDlg, (LPPOINT) &info.rcWindow, 2);
hdc = BeginPaint( hDlg, &ps );
TRACE("erase %d, rect=(%d,%d)-(%d,%d)\n", ps.fErase,
ps.rcPaint.left, ps.rcPaint.top,
ps.rcPaint.right, ps.rcPaint.bottom);
/* Paint frame */
MoveToEx( hdc, info.rcWindow.left, info.rcWindow.bottom, NULL );
hOrigPen=SelectObject( hdc, CreatePen( PS_SOLID, 2,
GetSysColor( COLOR_3DSHADOW ) ));
LineTo( hdc, info.rcWindow.left, info.rcWindow.top );
LineTo( hdc, info.rcWindow.right, info.rcWindow.top );
DeleteObject(SelectObject( hdc, CreatePen( PS_SOLID, 2,
GetSysColor( COLOR_3DLIGHT ) )));
LineTo( hdc, info.rcWindow.right, info.rcWindow.bottom );
LineTo( hdc, info.rcWindow.left, info.rcWindow.bottom );
DeleteObject(SelectObject( hdc, hOrigPen ));
/* Draw the sample text itself */
info.rcWindow.right--;
info.rcWindow.bottom--;
info.rcWindow.top++;
info.rcWindow.left++;
hOrigFont = SelectObject( hdc, CreateFontIndirectW( &lf ) );
SetTextColor( hdc, lpcf->rgbColors );
DrawTextW( hdc,
sample_lang_text[CHARSET_ORDER[lpcf->lpLogFont->lfCharSet]],
-1, &info.rcWindow, DT_CENTER|DT_VCENTER|DT_SINGLELINE );
DeleteObject(SelectObject( hdc, hOrigFont ));
EndPaint( hDlg, &ps );
}
return FALSE;
}
/***********************************************************************
* FormatCharDlgProcA [internal]
*/
INT_PTR CALLBACK FormatCharDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
LPARAM lParam)
{
LPCHOOSEFONTW lpcfw;
LPCHOOSEFONTA lpcfa;
INT_PTR res = FALSE;
int len;
if (uMsg!=WM_INITDIALOG) {
lpcfw = (LPCHOOSEFONTW)GetPropW(hDlg, strWineFontData);
if (!lpcfw)
return FALSE;
if (CFn_HookCallChk32(lpcfw))
res=CallWindowProcA((WNDPROC)lpcfw->lpfnHook, hDlg, uMsg, wParam, lParam);
if (res)
return res;
} else {
lpcfa=(LPCHOOSEFONTA)lParam;
SetPropW(hDlg, strWineFontData_a, (HANDLE)lParam);
lpcfw = HeapAlloc(GetProcessHeap(), 0, sizeof(CHOOSEFONTW));
memcpy(lpcfw, lpcfa, sizeof(CHOOSEFONTA));
lpcfw->lpLogFont = HeapAlloc(GetProcessHeap(), 0, sizeof(LOGFONTW));
memcpy(lpcfw->lpLogFont, lpcfa->lpLogFont, sizeof(LOGFONTA));
MultiByteToWideChar(CP_ACP, 0, lpcfa->lpLogFont->lfFaceName,
LF_FACESIZE, lpcfw->lpLogFont->lfFaceName, LF_FACESIZE);
if((lpcfa->Flags & CF_USESTYLE) && lpcfa->lpszStyle) {
len = MultiByteToWideChar(CP_ACP, 0, lpcfa->lpszStyle, -1, NULL, 0);
lpcfw->lpszStyle = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, lpcfa->lpszStyle, -1, lpcfw->lpszStyle, len);
}
if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcfw))
{
TRACE("CFn_WMInitDialog returned FALSE\n");
return FALSE;
}
if (CFn_HookCallChk32(lpcfw))
return CallWindowProcA((WNDPROC)lpcfa->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
}
switch (uMsg)
{
case WM_MEASUREITEM:
return CFn_WMMeasureItem(hDlg, wParam, lParam);
case WM_DRAWITEM:
return CFn_WMDrawItem(hDlg, wParam, lParam);
case WM_COMMAND:
return CFn_WMCommand(hDlg, wParam, lParam, lpcfw);
case WM_DESTROY:
return CFn_WMDestroy(hDlg, wParam, lParam, lpcfw);
case WM_CHOOSEFONT_GETLOGFONT:
TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n", lParam);
FIXME("current logfont back to caller\n");
break;
case WM_PAINT:
return CFn_WMPaint(hDlg, wParam, lParam, lpcfw);
}
return res;
}
/***********************************************************************
* FormatCharDlgProcW [internal]
*/
INT_PTR CALLBACK FormatCharDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam,
LPARAM lParam)
{
LPCHOOSEFONTW lpcf;
INT_PTR res = FALSE;
if (uMsg!=WM_INITDIALOG)
{
lpcf=(LPCHOOSEFONTW)GetPropW(hDlg, strWineFontData);
if (!lpcf)
return FALSE;
if (CFn_HookCallChk32(lpcf))
res=CallWindowProcW((WNDPROC)lpcf->lpfnHook, hDlg, uMsg, wParam, lParam);
if (res)
return res;
}
else
{
lpcf=(LPCHOOSEFONTW)lParam;
if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf))
{
TRACE("CFn_WMInitDialog returned FALSE\n");
return FALSE;
}
if (CFn_HookCallChk32(lpcf))
return CallWindowProcW((WNDPROC)lpcf->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
}
switch (uMsg)
{
case WM_MEASUREITEM:
return CFn_WMMeasureItem(hDlg, wParam, lParam);
case WM_DRAWITEM:
return CFn_WMDrawItem(hDlg, wParam, lParam);
case WM_COMMAND:
return CFn_WMCommand(hDlg, wParam, lParam, lpcf);
case WM_DESTROY:
return TRUE;
case WM_CHOOSEFONT_GETLOGFONT:
TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n", lParam);
FIXME("current logfont back to caller\n");
break;
case WM_PAINT:
return CFn_WMPaint(hDlg, wParam, lParam, lpcf);
}
return res;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -