在CEdit控件上设置粗体 [英] Setting a bold font on a CEdit control

查看:405
本文介绍了在CEdit控件上设置粗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已成功更改了CEdit控件的颜色和背景,但无法将其文本字体更改为 bold .

请帮助我完成此任务.

无论如何,谢谢.

I have sucessfully changed the color and the back ground of a CEdit control, but I am unable to change its text font to bold.

Help me please to accomplish this.

Thank you anyway.

推荐答案

发布您现在的代码,这样会更容易发现问题所在.

[更新]
~~~~~~~~~

自从我用MFC做类似的事情已经有一段时间了,但是我很快给了它一个测试,就像在编辑控件上调用SetFont 一样简单.

Post the code you have now, it''ll be easier to spot what''s wrong that way.

[Update]
~~~~~~~~~

Been a while since I did anything like that with MFC, but I quickly gave it a test, and it''s as simple as calling SetFont on the edit control.

GetDlgItem(IDC_EDIT1)->SetFont(&m_editFont);


尝试以下操作:

Try this:

void makebold(HWND hwnd)
{
	HFONT hFontB,hFont = (HFONT)SendMessage(hwnd,WM_GETFONT,0,0);
	LOGFONT lf;
	GetObject(hFont, sizeof(LOGFONT), &lf);
	lf.lfWeight = FW_BOLD;
	hFontB = CreateFontIndirect(&lf);
	SendMessage(hwnd,WM_SETFONT,(int)hFontB,1);
}



要传递的参数是CEdit控件中的m_hWnd.



The argument to pass is the m_hWnd from your CEdit control.


这篇关于在CEdit控件上设置粗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆