void CAPITest_EXEDlg::OnBtnFont()
{
CWnd* h=GetDlgItem(IDC_STATIC1);
CFont* pFont=h->GetFont();
LOGFONT lf;
pFont->GetLogFont(&lf);
lf.lfWeight=FW_BOLD;
pFont->CreateFontIndirect(&lf);//此处发生断言中断,好像是m_hObject为NULL
h->SetFont(pFont);
pFont->DeleteObject();
}
这是为什么?
{
CWnd* h=GetDlgItem(IDC_STATIC1);
CFont* pFont=h->GetFont();
LOGFONT lf;
pFont->GetLogFont(&lf);
lf.lfWeight=FW_BOLD;
pFont->CreateFontIndirect(&lf);//此处发生断言中断,好像是m_hObject为NULL
h->SetFont(pFont);
pFont->DeleteObject();
}
这是为什么?
解决方案 »
- 一个演示程序
- 求 vt1413 high -speed scanning a/d converter 说明文档
- asc数据文件中间隔是多个空格、每行首1或2个空格---应该怎么读取?请教代码
- 有人用过CSerialPort串口类吗?关于Dll获得View窗口菌病的问题
- 哪位高人能写出这种排列组合的算法?
- fu6canzhong请进
- 字符串中去掉一个特定的字符?
- 善良的石头同志:welcome
- 有谁能帮我解释一下回调函数?能不能讲一下一般它应用的地方
- HELP !!!我把我的可执行的应用程序做成NT下的服务,可启动服务时总报错“服务没有响应控制功能”,哪位高手能帮我????
- 用CSocket做的客户端和服务器端可以用同一个IP和同一个端口吗??
- 请问哪里可以下载到类似vc界面,左边有一个浮动窗口
先DeleteObject再CreateFontIndirect呢
CFont* pFont=h->GetFont();
LOGFONT lf;
pFont->GetLogFont(&lf);
lf.lfWeight=FW_BOLD;
pFont->DeleteObject();
pFont->CreateFontIndirect(&lf);
h->SetFont(pFont);
pFont->DeleteObject();
Font.CreateFontIndirect(&lf);
h->SetFont(&Font);
感觉羽战士的正确。横秋的应该也不会错。
但是
横秋:Font为什么要定义成static。
XP + VC6SP6,我的环境。横秋的代码没有获得当前的字体属性,而是用static来储存以前的字体信息。