dialog caption

Hi,

How do I make a dialog caption in the center of the dialog?
The problem we are having if we manually center the caption of the dialog it works in windows XP however, in NT it's
moving to the right.

Thanks
pbsmbc
pbsmbcAsked:
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.

minnirokCommented:
How are you manually drawing it at the moment? And what do you mean by it doesn't work under NT, it's not really centered, won't draw at all, etc?

Here's a draw text function for drawing centered text within a rect:

void DrawText(CDC* pdc, const CString& strText, CRect& rcRect)
{
     CRect rcSavedRect = rcRect;
     CRect rcNewRect = rcRect;
     CRgn rgn;

     rgn.CreateRectRgn(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom);

     // Call DrawText with DT_WORDBREAK | DT_CALCRECT flags, this will adjust the rectagle size
     // after breaking it into lines but without drawing

     pdc->DrawText(strText, &rcSavedRect,  DT_WORDBREAK | DT_CALCRECT | DT_CENTER | DT_VCENTER);

     // Modify the caption rectagle according to the new coordinates
     rcNewRect.top = rcRect.top + (rcRect.Height() - rcSavedRect.Height()) / 2;
     rcNewRect.bottom = rcRect.top + rcSavedRect.Height();
     
     HRGN hrgnOld = NULL;
     ::GetClipRgn(pdc->m_hDC, hrgnOld);

     pdc->SelectClipRgn(&rgn, RGN_COPY);

     // Draw the caption
     pdc->DrawText(strText, &rcNewRect, DT_WORDBREAK | DT_CENTER | DT_VCENTER);

     ::SelectClipRgn(pdc->m_hDC, hrgnOld);

     DeleteObject(rgn);
}

http://www.experts-exchange.com/Programming/Programming_Languages/MFC/Q_21375994.html?query=center+caption&clearTAFilter=true
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.