?
Solved

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

Posted on 2002-06-27
5
Medium Priority
?
1,063 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 800 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

719 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