如何从CEdit中拿到字体? 如何从CEdit中拿到字体,我想拿到CFont,或是logfont,我现在用getfont是拿不到字体,还有如何拿到CDC?GetDC好像是不行,CPaintDC dc(this)好像也不大对,主要是这两个dc中拿不到CFont。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 CWnd::GetFont CFont* GetFont( ) const;Return ValueA pointer to a CFont that contains the current font. The pointer may be temporary and should not be stored for later use. 我的类是继承自CEdit,在 CEDEditBox::OnChar中 CDC* pDC = this->GetDC(); CFont* pFont = this->GetFont(); LOGFONT lf; memset(&lf,0,sizeof(LOGFONT)); pFont->GetLogFont(&lf);这个时候的lf为全0,我当然是拿不到字体阿 我最主要的目的是拿到字宽void CEDEditBox::OnPaint(){ CPaintDC dc(this); CFont font; font.CreateFontIndirect(&m_lf);//m_lf.lfHeight = 15; CFont* pOldFont = dc.SelectObject(&font); CSize size = dc.GetTextExtent(str);//str中是有值的 //这时size 为(0,0);不知道为什么! 拿不到值我就没有办法进行后续工作。 dc.SelectObject(pOldFont);} vc6 调试 数据断点 VC2005中ALT OLEDB使用者总是出错,请问这是为什么? 求用Mscomm控件编写的串口选择代码 求助:怎么把server端做成一个service,给高分,谢谢 //给个完整hook api的例子。 unicode和多字节转换 打开文件后,我如何一个一个字符的把文件从头读到尾? 求助 获取资源中对话框的尺寸 请问哪位有空给我上一课----父窗口子窗口都是怎么一回事呀? 把view里的东西保存成为图像。 谁有MFC的资源管理器的例子代码?
CFont* GetFont( ) const;Return ValueA pointer to a CFont that contains the current font. The pointer may be temporary and should not be stored for later use.
CDC* pDC = this->GetDC();
CFont* pFont = this->GetFont();
LOGFONT lf;
memset(&lf,0,sizeof(LOGFONT));
pFont->GetLogFont(&lf);这个时候的lf为全0,我当然是拿不到字体阿
{
CPaintDC dc(this);
CFont font;
font.CreateFontIndirect(&m_lf);//m_lf.lfHeight = 15;
CFont* pOldFont = dc.SelectObject(&font);
CSize size = dc.GetTextExtent(str);//str中是有值的
//这时size 为(0,0);不知道为什么! 拿不到值我就没有办法进行后续工作。
dc.SelectObject(pOldFont);
}