set height of output window

hi,
I have an output window in my application, based on an CEdit object. (with multiline style)
I set its height to contain 2 lines(if working on small fonts).
The problem is that when working in large fonts I can see only a little bit more than one line.
how can I calculate the height which I need to set the CEdit Ctrl, in a way that it will contain 2 lines both in small and large fonts ??

Yoav.
yoavoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vinayak KumbarSr Program ManagerCommented:
Hi,

If U can get the font type(small or large), then using that calculate the height(may be it will be constant), then set the hieght of the edit control using the MoveWindow() function.

((CEdit *)GetDlgItem(ID_EDIT1))->MoveWindow(...);

Try it out.

VinExpert
0
Vinayak KumbarSr Program ManagerCommented:
Hi,

Just try by putting this code in the OnIntitDialog for that dialog.
TEXTMETRIC txtmat;      
CRect rect;
CClientDC dc(this);
dc.GetTextMetrics(&txtmat);
      
m_ctrlFontEdit.GetWindowRect(&rect);
ScreenToClient(&rect);
      m_ctrlFontEdit.SetWindowPos(&m_ctrlFontEdit.wndTop,10,10, 100, txtmat.tmHeight*2, SWP_SHOWWINDOW);

Here m_ctrlFontEdit in the control variable to that edit control.

Try it out.
VinExpert
0
captainkirkCommented:
Actually, use txtmat.tmHeight + txtmat.tmExternalLeading to get the height of your line...
0
Vinayak KumbarSr Program ManagerCommented:
Hi,

This should solve Ur problem

TEXTMETRIC txtmat;      
CRect rect;
CFont *font = this->GetFont();

CClientDC dc(this);
dc.SelectObject(font);
dc.GetTextMetrics(&txtmat);
      
m_ctrlFontEdit.GetWindowRect(&rect);
ScreenToClient(&rect);
      m_ctrlFontEdit.SetWindowPos(&m_ctrlFontEdit.wndTop,10,10, 100, (txtmat.tmHeight + txtmat.tmExternalLeading)*2, SWP_SHOWWINDOW);

Hope this helps.
VinExpert
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.