Re: Problem with window size depending on desktop settings

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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
.



Relevant Pages

  • [Tk] hard resizing
    ... And scrollbars: .ar.sx, .ar.sy ... a window .ar.c.f is created on canvas. ... The .ar frame seems to start with predefined height. ...
    (comp.lang.tcl)
  • Re: [Tk] grid+canvas+window = resize problem
    ... The canvas is "gridded" in upper left corner, then there are scrollbars at ... The problem is that when I resize the top-level window, the canvas does not ... scrollable frame. ...
    (comp.lang.tcl)
  • Re: Tkinter Scrolling
    ... ## Grid sizing behavior in window ... ## Scrollbars for canvas ... ## This puts the frame in the canvas's scrollable zone ...
    (comp.lang.python)
  • Re: Question on scrolled frames
    ... > level window is enlarged. ... The scrollable frame is working just fine. ... scrollbars to move that window around. ... If you want widget sizes to expand and contract when the top level ...
    (comp.lang.tcl)
  • Re: Atomic clock behaviour in a gravitational field explained with 1905 Relativity
    ... in the frame of the Sun my desk has the same movement as ... Outside my window is a tree, ... Then for the same point p in X and X', the transformation ... with the same velocity, then in one anothers frame they are ...
    (sci.physics.relativity)