15,979
社区成员
发帖
与我相关
我的任务
分享
class myEdit : public CMFCToolBarEditBoxButton
{
public:
DECLARE_SERIAL(myEdit)
CFont m_font;
myEdit()
{
m_iWidth = 300;
VERIFY(m_font.CreateFont(
18, // nHeight
0, // nWidth
0, // nEscapement
0, // nOrientation
FW_NORMAL, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
0, // cStrikeOut
ANSI_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
_T("Arial"))); // lpszFacename
}
void OnChangeParentWnd(CWnd* pWndParent)
{
CMFCToolBarEditBoxButton::OnChangeParentWnd(pWndParent);
m_pWndEdit->SetFont(&m_font); // <<<<<<<<<<<<<<< 设置字体
}
void OnMove()
{
if (m_pWndEdit->GetSafeHwnd() == NULL ||
(m_pWndEdit->GetStyle() & WS_VISIBLE) == 0)
{
return;
}
int cy = afxGlobalData.GetTextHeight() + 6;
int yOffset = max(0, (m_rect.Height() - m_sizeText.cy - cy) / 2);
m_pWndEdit->SetWindowPos(NULL, m_rect.left + 3, m_rect.top + yOffset, m_rect.Width() - 2 * 3, cy, SWP_NOZORDER | SWP_NOACTIVATE);
m_pWndEdit->SetSel(-1, 0);
}
};