Solved

Convert Pixel to Dlg unit

Posted on 1998-06-19
1
424 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 11

Accepted Solution

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

B ekiM
0

Featured Post

Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

617 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