如过要改变static中所有的字,可以使用SetFont函数
如果要字体不同,就要自己写OnPaint函数了
如果要字体不同,就要自己写OnPaint函数了
解决方案 »
- 想用select 模型实现TCP并发服务器,大家指点一下啊 谢谢了
- 字符串截取 希望大家各抒己见 自由题
- 如何枚举网络连接
- 求助!!!!!!!!!关于winsocket.
- 如何读取ntfs格式中系统隐藏的16个文件?
- 在使用connect连接服务时,如何设置其超时时间为10s?
- ADO求助,已找到函数原型,SQL server数据库连接不上,异常为:DB_SEC_E_AUTH_FAILED ,IDispatch error #3149
- 菜鸟求助:请教1、如何使VC++对话框中的控件自由拉伸?2、如何在VC++中加载OCX第三方控件?
- 怎么往数据库里添加记录》
- 懂VC做Autocad二次开发或熟悉AutoCad的朋友请帮帮忙
- 怎么定义可调数组?
- 100分问题。请到 http://www.csdn.net/expert/topic/728/728422.xml?temp=.3291742
Cfont &font
//设置字体等
setwindowstext()
請舉個例子好嗎?字體怎么設置呢?Cfont如何使用呢?
CFont m_fontSample;
m_fontSample.CreatePointFont(80,_T("MS Sans Serif"));
//设计成你需要地字体
GetDlgItem(IDC_SAMPLETEXT)->SetFont(&m_fontSample);
//IDC_SAMPLETEXT为靜態文本控件的ID.
否则,刷新后还是按原来对话框的默认字体显示
如果,不在Ondraw里面这么做,只好自己写个类了
我做的是一个对话框程式。
void CSamDlg::OnDraw()
{
CFont m_fontSample;
m_fontSample.CreatePointFont(390,_T("Verdana 粗体"));
GetDlgItem(IDC_SAM)->SetFont(&m_fontSample);
m_Sam.SetWindowText("你好");
}
OnLine Waiting....
在你需要改变的地方加入如下代码:
CFont m_fontSample;
m_fontSample.CreatePointFont(80,_T("MS Sans Serif"));
//设计成你需要地字体
GetDlgItem(IDC_SAMPLETEXT)->SetFont(&m_fontSample);
//IDC_SAMPLETEXT为靜態文本控件的ID.
这个方法可行,我实现过。(可以在INITIAL DIALOG里设置。)
BOOL CSamDlg::OnInitDialog()
{
CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
} // Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
CFont m_fontSample;
m_fontSample.CreatePointFont(390,_T("Verdana 粗体"));
GetDlgItem(IDC_SAM)->SetFont(&m_fontSample);
m_Sam.SetWindowText("你好");
// Sleep(1000); return TRUE; // return TRUE unless you set the focus to a control
}
了原狀,我要讓它一直顯示怎么辦?
void CSamDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon
dc.DrawIcon(x, y, m_hIcon);
OnDraw(); }
else
{
CDialog::OnPaint();
OnDraw();
}
OnDraw();
}
use:
CFont m_font;
m_fontSample.CreatePointFont(390,Font name you need);
GetDlgItem(Your Static ID)->SetFont(&m_font);or you can use subclass create your own class of static
m_fontSample.CreatePointFont(390,Font name you need);
GetDlgItem(Your Static ID)->SetFont(&m_font);
m_font.Detach();
ADD TO 50 fen.
THANKS!
加入成员
CFont fnt;
LOGFONT lf;
// 设置字体
在CMyStatic::OnDraw()中选择字体设备位子定义的那个就可以拉
thanks lanzhengpeng2