15,980
社区成员
发帖
与我相关
我的任务
分享
// CVertCenterEdit message handlers
void CVertCenterEdit::SetEditVertCenter()
{ // set rc.Height() = size.cy !
CRect rc;
GetClientRect(&rc);
CDC* pDC=GetDC();
CFont *pFont =GetFont();
HGDIOBJ hOld = pDC->SelectObject(pFont);//&m_FontVertEdit);
//
SIZE size;
GetTextExtentPoint32W (pDC->m_hDC, L"f", 1, &size) ;//34
pDC->SelectObject(hOld);
//
afxDump << rc.Height() << "\n";// 76
//
if(rc.Height() > size.cy)
rc.DeflateRect(0, (rc.Height() - size.cy)/2);
else
afxDump << "rc.Height too small !" << "\n";
//
SetRect(&rc);
}
void CVertCenterEdit::PreSubclassWindow()
{
// TODO: Add your specialized code here and/or call the base class
#ifndef EDIT_NO_FONT
m_FontVertEdit.CreateFont(34, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE
, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_TT_ALWAYS, PROOF_QUALITY
, VARIABLE_PITCH | FF_SWISS, TEXT("SANS SERIF"));
SetFont(&m_FontVertEdit);
#endif
SetEditVertCenter();
CEdit::PreSubclassWindow();
}