Solved

Convert Pixel to Dlg unit

Posted on 1998-06-19
1
414 Views
Last Modified: 2013-11-20
I need to size a dialog box to that exactly of a bitmap.
How do I convert the bitmap's width & height (in pixel)
to that of dialog's unit?  

Below  is the code which i think might work.
Is there any better method?

// load bitmap
HBITMAP hBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),
                         MAKEINTRESOURCE(IDB_BITMAP1),
                         IMAGE_BITMAP,
                         0,0,
                         LR_LOADMAP3DCOLORS);

if (hBmp!= NULL)
{
  BITMAP   bmInfo;
  int result = ::GetObject(hBmp, sizeof(BITMAP), &bmInfo);

  if (result != 0)
  {
   // calculate dlg box size based in bitmap size
   int nNewDlgHeight = ConvertToDlgUnit(bmInfo.bmHeight); //???? How to convert
   int nNewDlgWidtht = ConvertToDlgUnit(bmInfo.bmWidth); //????
   
   // Set dlg box new size
   WINDOWPLACEMENT lpwndpl ;
    GetWindowPlacement(&lpwndpl );
    lpwndpl.rcNormalPosition.bottom = lpwndpl.rcNormalPosition.top + nNewDlgHeight ;
    lpwndpl.rcNormalPosition.right = lpwndpl.rcNormalPosition.left + nNewDlgWidth ;
    SetWindowPlacement(&lpwndpl );
  }
}
0
Comment
Question by:engllf
1 Comment
 
LVL 11

Accepted Solution

by:
mikeblas earned 50 total points
ID: 1318253
To convert, use MapDialogRect().

B ekiM
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
only14 challenge 19 64
no14 challenge 14 57
zeroMAx challenge 20 77
how to split multiple lines delimiter : 8 55
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now