Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Convert DLU to pixels

422 views
Skip to first unread message

David Briggs

unread,
May 2, 2004, 8:59:01 PM5/2/04
to
I need to layout some child dialog dynamically. How can one convert from
DLU to pixels and back?
Thanks


Jeff Partch [MVP]

unread,
May 2, 2004, 9:41:54 PM5/2/04
to
"David Briggs" <s...@s.com> wrote in message
news:pPglc.49655$2v.1...@nwrdny02.gnilink.net...

> I need to layout some child dialog dynamically. How can one convert from
> DLU to pixels and back?

http://support.microsoft.com/default.aspx?scid=kb;en-us;125681
http://support.microsoft.com/default.aspx?scid=kb;en-us;145994

Additionally, AtlWin.h has an implementation of a ConvertDialogUnitsToPixels
function.

--
Jeff Partch [VC++ MVP]


Uwe Kotyczka

unread,
May 3, 2004, 9:01:43 AM5/3/04
to
"David Briggs" <s...@s.com> wrote in message news:<pPglc.49655$2v.1...@nwrdny02.gnilink.net>...
> I need to layout some child dialog dynamically. How can one convert from
> DLU to pixels and back?
> Thanks


int MapDialogUnitX(int nX, CWnd* pWnd)
{
ASSERT(::IsWindow(pWnd->GetSafeHwnd()));
CRect rect(0, 0, nX, 0);
if (MapDialogRect(pWnd->GetSafeHwnd(), &rect))
nX = rect.right;
else
{
TRACE("MapDialogUnitX: GetLastError returned %d.\n", GetLastError());
nX = -1;
}
return nX;
}

int MapDialogUnitY(int nY, CWnd* pWnd)
{
ASSERT(::IsWindow(pWnd->GetSafeHwnd()));
CRect rect(0, 0, 0, nY);
if (MapDialogRect(pWnd->GetSafeHwnd(), &rect))
nY = rect.bottom;
else
{
TRACE("MapDialogUnitY: GetLastError returned %d.\n", GetLastError());
nY = -1;
}
return nY;
}

HTH

Joseph M. Newcomer

unread,
May 3, 2004, 10:10:35 PM5/3/04
to
Mostly by ignoring their existence. I've ignored DBUs for the last 12 years or so without
harm. Can you describe your need for DBUs a bit more?
joe

Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

0 new messages