- // Update font. Note that we must delete previous font
- // before creating a new one.
- CFont * pFont = pWnd->GetFont();
- if (pFont)
- {
- m_pFont.reset(new CFont);
- if (m_pFont != NULL)
- {
- LOGFONT lfFont = {0};
- if (pFont->GetLogFont(&lfFont))
- {
- m_pFont->CreateFontIndirect(&lfFont);
- for (int pane = 0; pane < m_nPanes; pane++)
- {
- m_Edit[pane].SetFont(m_pFont.get());
- m_Edit[pane].SetMargins(4, 4);
- }
- }
- }
- }
-
- // Set same dimensions (than window we imitate)
- CRect rectNew;
- pWnd->GetWindowRect(rectNew);
- CRect rectCurrent;
- GetWindowRect(rectCurrent);
- if (rectNew != rectCurrent)
- {
- SetWindowPos(NULL,0,0,rectNew.Width(), rectNew.Height(),
- SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE);
- return TRUE;
- }
- return FALSE;
+ TEXTMETRIC tm;
+ CClientDC dc(this);
+ CFont *pOldFont = dc.SelectObject(&m_font);
+ dc.GetTextMetrics(&tm);
+ dc.SelectObject(pOldFont);
+ return CSize(SHRT_MAX, tm.tmHeight + 6);