Edit控件的字体和颜色
字体可以采用函数CreateFont来创建,如下面的例子所示
CFont fnt;
fnt.CreateFont(12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, _T("Lucida Console"));
m_Edit.SetFont(fnt);
fnt.Detach();
Edit控件的字体颜色,背景颜色需要在父窗口中处理消息WM_CTLCOLOREDIT,如下面的函数所示:
LRESULT OnCtlColorEdit(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
CDC dc((HDC)wParam);
HWND hwnd = (HWND)lParam;
HBRUSH hbr = 0;
if (m_Edit.m_hWnd == hwnd)
{
dc.SetTextColor(RGB(192,192,192));
dc.SetBkColor(RGB(0,0,0));
hbr = CreateSolidBrush(RGB(0,0,0));
bHandled = TRUE;
}
else
bHandled = FALSE;
dc.Detach();
return (LRESULT)hbr;
}
参考:http://forums.devx.com/showthread.php?t=83993
没有评论:
发表评论