Re: Problem with window size depending on desktop settings
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Tue, 03 Jan 2006 13:02:18 -0500
The suggested size you set is the startup size of the frame. When the dialog template is
instantiated, it is instantiated according to some mysterious conversion of Dialog Box
Units (DBUs) to pixels, and if the resulting pixels are larger than the size you have
selected, it will introduce scrollbars. In general, you can never, ever depend on some
compile time constant (which I presume the GUI_ values are) to set window sizes; they are
largely meaningless, as you already discovered.
Instead, I'd recommend creating an invisible static frame around your controls. Change
its ID from IDC_STATIC to some meaningful name, and create a control variable to represent
it (remember to uncheck the "visible" attribute). Now, when you get to OnInitialUpdate
(not in PreCreateWindow), you get the frame size. You then call ResizeParentToFit of that
size. This will guarantee that you don't get scrollbars no matter what the display driver
is doing to you. Note that on some machines with, say, 640x480 resolution, you may not be
able to fit the entire window on the screen (yes, I had this happen once; we ended up
changing the specs to require 800x600 resolution).
joe
On Tue, 03 Jan 2006 10:02:29 +0000, Jamie <None@xxxxxxxx> wrote:
>Hi,
>
>I have written an SDI application which displays a single CFormView. My
>CFormView is a fixed size form with various text components and buttons
>on. I want the application to have a fixed size so I have set it so that
>it cannot be resized. On the whole it works fine on 95% of machines, but
>I have found on the odd PC that scroll bars appear on the view. I
>believe this is due to desktop settings, such as extra large font size,
>different icon size etc.
>
>At the moment I set the window size as follows:
>
>BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
>{
> /* Set the Size of the GUI window */
> cs.cx = GUI_WIDTH;
> cs.cy = GUI_HEIGHT;
>
> cs.style = WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_SYSMENU;
>
> if( !CFrameWnd::PreCreateWindow(cs) )
> return FALSE;
>
> return TRUE;
>}
>
>How can I create my application so that it takes into account any
>windows desktop settings and creates a window of an appropriate size on
>all machines.
>
>Many thanks,
>
>Jamie
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- References:
- Prev by Date: Re: windows nt service
- Next by Date: Re: Search feature is needed in by date, name, id, telnumber, ...
- Previous by thread: Re: Problem with window size depending on desktop settings
- Next by thread: Re: Problem with window size depending on desktop settings
- Index(es):
Relevant Pages
|