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
Solved

Convert Pixel to Dlg unit

Posted on 1998-06-19
1
420 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

856 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