Loading ...
Sorry, an error occurred while loading the content.

How to persist CMainFrame location and size?

Expand Messages
  • politicalconfusion
    I have a CFrameWindowImpl -based window. In my WM_CREATE handler, I load values for the last location and size of the window and call MoveWindow() with them.
    Message 1 of 3 , Jun 4, 2008
    View Source
    • 0 Attachment
      I have a CFrameWindowImpl<>-based window. In my WM_CREATE handler, I
      load values for the last location and size of the window and call
      MoveWindow() with them. However, when wndMain.ShowWindow( nCmdShow )
      is called from Run(), WM_SIZE and WM_MOVE messages are received with
      different values from the ones I set. Are there any canonical WTL
      examples of persisting window location and size? I can set the
      location and size after wndMain.ShowWindow( nCmdShow ), but I get a
      quick flash of the window at the wrong size and location.
    • Dick Dievendorff
      I restore my main window s position and size in my main module s Run method, after calling wndMain.CreateEx and before ShowWindow. I save the main window s
      Message 2 of 3 , Jun 4, 2008
      View Source
      • 0 Attachment
        I restore my main window's position and size in my main module's Run method,
        after calling wndMain.CreateEx and before ShowWindow.



        I save the main window's position and size in the main window's OnDestroy
        handler.



        I use GetWindowPlacement and SetWindowPlacement and save each of the values
        in the registry.



        YMMV.



        Dick





        From: wtl@yahoogroups.com [mailto:wtl@yahoogroups.com] On Behalf Of
        politicalconfusion
        Sent: Wednesday, June 04, 2008 2:20 PM
        To: wtl@yahoogroups.com
        Subject: [wtl] How to persist CMainFrame location and size?



        I have a CFrameWindowImpl<>-based window. In my WM_CREATE handler, I
        load values for the last location and size of the window and call
        MoveWindow() with them. However, when wndMain.ShowWindow( nCmdShow )
        is called from Run(), WM_SIZE and WM_MOVE messages are received with
        different values from the ones I set. Are there any canonical WTL
        examples of persisting window location and size? I can set the
        location and size after wndMain.ShowWindow( nCmdShow ), but I get a
        quick flash of the window at the wrong size and location.





        [Non-text portions of this message have been removed]
      • politicalconfusion
        Thanks. That works perfectly. I find it strange that MoveWindow in the same place (between CreateEx and ShowWindow) doesn t. But I guess SetWindowPlacement
        Message 3 of 3 , Jun 5, 2008
        View Source
        • 0 Attachment
          Thanks. That works perfectly. I find it strange that MoveWindow in
          the same place (between CreateEx and ShowWindow) doesn't. But I guess
          SetWindowPlacement is a little more involved (and the canonical way to
          do it).


          --- In wtl@yahoogroups.com, "Dick Dievendorff" <dieven@...> wrote:
          >
          > I restore my main window's position and size in my main module's Run
          method,
          > after calling wndMain.CreateEx and before ShowWindow.
          >
          >
          >
          > I save the main window's position and size in the main window's
          OnDestroy
          > handler.
          >
          >
          >
          > I use GetWindowPlacement and SetWindowPlacement and save each of the
          values
          > in the registry.
          >
          >
          >
          > YMMV.
          >
          >
          >
          > Dick
          >
          >
          >
          >
          >
          > From: wtl@yahoogroups.com [mailto:wtl@yahoogroups.com] On Behalf Of
          > politicalconfusion
          > Sent: Wednesday, June 04, 2008 2:20 PM
          > To: wtl@yahoogroups.com
          > Subject: [wtl] How to persist CMainFrame location and size?
          >
          >
          >
          > I have a CFrameWindowImpl<>-based window. In my WM_CREATE handler, I
          > load values for the last location and size of the window and call
          > MoveWindow() with them. However, when wndMain.ShowWindow( nCmdShow )
          > is called from Run(), WM_SIZE and WM_MOVE messages are received with
          > different values from the ones I set. Are there any canonical WTL
          > examples of persisting window location and size? I can set the
          > location and size after wndMain.ShowWindow( nCmdShow ), but I get a
          > quick flash of the window at the wrong size and location.
          >
          >
          >
          >
          >
          > [Non-text portions of this message have been removed]
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.