如题,我在主窗口上使用createwindow方法创建了若干button,edit及static控件,代码如下:
CreateWindow(TEXT("static"), TEXT("XXXXXXXXXXXXXXXX"), WS_CHILD | WS_VISIBLE,
25, 79, 235, 20 ,hwnd, (HMENU)5, ((LPCREATESTRUCT) lParam)->hInstance, NULL);
但是控件上显示的字体比较难看,是粗体而且不是等宽的,如果我想改变字体,应该怎么做呢?
另外如果我想使字体与windows当前使用的字体一致,应该怎么获取windows当前使用的字体呢?
谢谢大家
CreateWindow(TEXT("static"), TEXT("XXXXXXXXXXXXXXXX"), WS_CHILD | WS_VISIBLE,
25, 79, 235, 20 ,hwnd, (HMENU)5, ((LPCREATESTRUCT) lParam)->hInstance, NULL);
但是控件上显示的字体比较难看,是粗体而且不是等宽的,如果我想改变字体,应该怎么做呢?
另外如果我想使字体与windows当前使用的字体一致,应该怎么获取windows当前使用的字体呢?
谢谢大家
有详细介绍
HBRUSH CMy10MinutesDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if(pWnd->GetDlgCtrlID()==IDC_STATIC_TIME)
{
pDC->SetTextColor(RGB(255,0,0));
pDC->SetBkMode(TRANSPARENT);
} if(pWnd->GetDlgCtrlID()==IDC_BUTTON_END)
{
pDC->SetTextColor(RGB(255,0,0));
//pDC->SetBkMode(TRANSPARENT);
pDC->SetBkColor(RGB(0,255,0));
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
下面是改变控件字体大小等...
VERIFY(font.CreateFont(
36, // nHeight
0, // nWidth
0, // nEscapement
0, // nOrientation
FW_NORMAL, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
0, // cStrikeOut
ANSI_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
"Arial")); // lpszFacename
GetDlgItem(IDC_STATIC_TIME)->SetFont(&font);
Retrieves the window's current font by sending a WM_GETFONT message to the window.
HFONT GetFont( ) const throw();
Return Value
A font handle.2,CWnd::GetFont()
Gets the current font for this window.
CFont* GetFont( ) const;
Return Value
A pointer to a CFont that contains the current font.
The pointer may be temporary and should not be stored for later use.