Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / desktop / MFC

Convert Dialog Resource Units to Pixels

5.00/5 (1 vote)
15 Sep 2011CPOL 17.2K  
This tip shows you how to convert the dimension values in the .rc file of a dialog into pixels
Given a rectangle rcDlg which contains the rc file coordinates of a dialog resource, use the following code:

C#
CDialog *pDlg = m_pDlg;
 pDlg->MapDialogRect(&rcDlg);
 ::AdjustWindowRectEx(&rcDlg,
                             pDlg->GetStyle(),
        ::IsMenu(::GetMenu(pDlg->GetSafeHwnd())),
                             pDlg->GetExStyle());

 pDlg->ClientToScreen(&rcDlg);


P.S. Special thanks goes to Jacques Raphanel for this solution.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)