Solved

Resize Property Page to fit bitmap (using SDK - not MFC)

Posted on 2002-06-27
5
1,060 Views
Last Modified: 2013-12-03
Hello,

I am building a property page using Visual C++ Windows SDK (Non-MFC) and I want my property page to be bitmap based.  The only thing I want displayed int the Property Page display region is a bitmap and the program will respond to mouse movements and button control.  

The problem is that the Property Page is defined in a .rc file as a dialog as follows and as you see the size of the dialog is based on DIALOG UNITS although I would prefer to define the size in pixels so that it will exactly fit my bitmap:

IDD_MYPROPPAGE DIALOG DISCARDABLE  0, 0, 140, 180
STYLE WS_CHILD
FONT 8, "MS Sans Serif"
BEGIN
END

Since I cannot define the dialog in pixels, I guess I will need to resize it after it is created so that it is the proper size.  How can I do that?

Thanks,
Mark
0
Comment
Question by:kaplan1
[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
  • 2
5 Comments
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 7115638
Displays the settings for the grid spacing in dialog box units (DLUs).

Width: DLUs
Sets the width of the layout grid in DLUs. A horizontal DLU is the average width of the dialog box font divided by four.
Height: DLUs
Sets the height of the layout grid in DLUs. A vertical DLU is the average height of the dialog box font divided by eight


MSDN SAYS:

BOOL CMyDlg::OnInitDialog()
{
    CDialog::OnInitDialog();

    // Set tabstops at 100 and 200 dialog units
    int tab_stop[2] = {100, 200};
    VERIFY(m_listbox.SetTabStops(2, tab_stop));

    m_listbox.AddString("String1\tString2\tString3");

    CDC *pDC = m_listbox.GetDC();

    // Get a handle to the font used in the list box
    CFont *pFont;
    pFont = m_listbox.GetFont();

    // Select the list box font into the temporary DC
    CFont *pFontOld = pDC->SelectObject(pFont);

    // Call GetTextExtentPoint to compute the string dimensions
    // NOTE: use GetTextExtentPoint32 in Win32 for better results
    CSize size;
    GetTextExtentPoint(pDC->GetSafeHdc(),
      "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
      52, &size);

    int avg_char_width = (size.cx/26 +1)/2;

    // Restore Original Font
    pDC->SelectObject(pFontOld);

    m_listbox.ReleaseDC(pDC);

    // Convert DLU to pixel positions
    int xPos1 = (tab_stop[0] * avg_char_width + 2)/4;
    int xPos2 = (tab_stop[1] * avg_char_width + 2)/4;
...........
}

GOOD LUCK
0
 

Author Comment

by:kaplan1
ID: 7116845
What I am trying to accomplish is to set the dialog box associated with my Property page to be an exact height and width of pixels.  Since the dialog definition in the .rc file is in DLU's which seem to be user dependent (depends on users screen resolution) I don't think I can set it there.  Therefore I assume I must resize the dialog box at runtime to the exact pixel dimensions that I want.  Is this possible, and if so how?

Thanks,
Mark
0
 
LVL 8

Accepted Solution

by:
fl0yd earned 200 total points
ID: 7123620
This is possible. Use the SetWindowPos()-function and specifiy ( SWP_NOMOVE | SWP_NOREPOSITION | SWP_NOZORDER ) as your flags. All window/display-functions take actual pixel dimensions, with one exception: printing.
0
 

Author Comment

by:kaplan1
ID: 7125549
I tried using SetWindowPos() but nothing happened.  That is probably because the dialog box of the Property Page is a child of the outer TabCtrl.  
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

734 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