Solved

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

Posted on 2002-06-27
5
1,062 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…

623 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