65.9K
CodeProject is changing. Read more.
Home

Convert Dialog Resource Units to Pixels

starIconstarIconstarIconstarIconstarIcon

5.00/5 (1 vote)

Sep 12, 2011

CPOL
viewsIcon

17233

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:
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.