Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. set size of main application window at startup

set size of main application window at startup

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    elephantstar
    wrote on last edited by
    #1

    Hi there, How can I set the main applicatin window to a certain size at startup? With the code below, it sizes to the set size only when the Restore button is clicked. I'd like it to be that size when the application starts up. How can I manage this? Thanks! BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { if( !CMDIFrameWnd::PreCreateWindow(cs) ) return FALSE; cs.style = WS_OVERLAPPED | WS_CAPTION | WS_THICKFRAME | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX; cs.cx = 1000; cs.cy = 800; cs.x = 100; cs.y = 100; return CMDIFrameWnd::PreCreateWindow(cs); }

    H 1 Reply Last reply
    0
    • E elephantstar

      Hi there, How can I set the main applicatin window to a certain size at startup? With the code below, it sizes to the set size only when the Restore button is clicked. I'd like it to be that size when the application starts up. How can I manage this? Thanks! BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { if( !CMDIFrameWnd::PreCreateWindow(cs) ) return FALSE; cs.style = WS_OVERLAPPED | WS_CAPTION | WS_THICKFRAME | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX; cs.cx = 1000; cs.cy = 800; cs.x = 100; cs.y = 100; return CMDIFrameWnd::PreCreateWindow(cs); }

      H Offline
      H Offline
      heman154
      wrote on last edited by
      #2

      Use the following Cwnd function, BOOL SetWindowPos( const CWnd* pWndInsertAfter, int x, int y, int cx, int cy, UINT nFlags ); Do a search on this fcn in msdn to find out more.

      E 1 Reply Last reply
      0
      • H heman154

        Use the following Cwnd function, BOOL SetWindowPos( const CWnd* pWndInsertAfter, int x, int y, int cx, int cy, UINT nFlags ); Do a search on this fcn in msdn to find out more.

        E Offline
        E Offline
        elephantstar
        wrote on last edited by
        #3

        This function is only for child windows and popups. How can I size the main window not the child window? Thanks.

        H T 2 Replies Last reply
        0
        • E elephantstar

          This function is only for child windows and popups. How can I size the main window not the child window? Thanks.

          H Offline
          H Offline
          heman154
          wrote on last edited by
          #4

          Have you tryed it? It's always worked for me. If you go on MSDN, the actual description is: "Call this member function to change the size, position, and Z-order of child, pop-up, and top-level windows." Also, make sure you put this in the OnCreate fcn.

          1 Reply Last reply
          0
          • E elephantstar

            This function is only for child windows and popups. How can I size the main window not the child window? Thanks.

            T Offline
            T Offline
            ThatsAlok
            wrote on last edited by
            #5

            You can do that by handlling [WM_GETMINMAXINFO] message too!

            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

            cheers, Alok Gupta

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups