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. Basic MFC question

Basic MFC question

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
5 Posts 5 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.
  • W Offline
    W Offline
    will1383
    wrote on last edited by
    #1

    Hello all, This is a basic question in MFC, but for some odd reason I can't figure out how to do it. I want to be able to specify the size of the main window when it comes up, and would like to be able to save this information (via .ini file I suppose). I thought that by modifying the CreateStruct in the OnCreate or the OnPreCreate would handle this setting the initiail size of the main window, but it does not work. Any suggestions on how to do this, and could anyone point me in the right direction to "save" this window information so when it comes up again I can use the last position/size information. Thank you in advance. Dan

    L R S J 4 Replies Last reply
    0
    • W will1383

      Hello all, This is a basic question in MFC, but for some odd reason I can't figure out how to do it. I want to be able to specify the size of the main window when it comes up, and would like to be able to save this information (via .ini file I suppose). I thought that by modifying the CreateStruct in the OnCreate or the OnPreCreate would handle this setting the initiail size of the main window, but it does not work. Any suggestions on how to do this, and could anyone point me in the right direction to "save" this window information so when it comes up again I can use the last position/size information. Thank you in advance. Dan

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      There are some articles on how to do this somewhere on this very site...


      When I am king, you will be first against the wall.

      1 Reply Last reply
      0
      • W will1383

        Hello all, This is a basic question in MFC, but for some odd reason I can't figure out how to do it. I want to be able to specify the size of the main window when it comes up, and would like to be able to save this information (via .ini file I suppose). I thought that by modifying the CreateStruct in the OnCreate or the OnPreCreate would handle this setting the initiail size of the main window, but it does not work. Any suggestions on how to do this, and could anyone point me in the right direction to "save" this window information so when it comes up again I can use the last position/size information. Thank you in advance. Dan

        R Offline
        R Offline
        Roman Fadeyev
        wrote on last edited by
        #3

        This site contains some examples of how to save and restore window position. I saw an article http://www.codeproject.com/docview/persistframes.asp[^] about storing and loading positions of SDI/MDI ChildFrame, MainFrame and so on more recently.

        1 Reply Last reply
        0
        • W will1383

          Hello all, This is a basic question in MFC, but for some odd reason I can't figure out how to do it. I want to be able to specify the size of the main window when it comes up, and would like to be able to save this information (via .ini file I suppose). I thought that by modifying the CreateStruct in the OnCreate or the OnPreCreate would handle this setting the initiail size of the main window, but it does not work. Any suggestions on how to do this, and could anyone point me in the right direction to "save" this window information so when it comes up again I can use the last position/size information. Thank you in advance. Dan

          S Offline
          S Offline
          Stephane Rodriguez
          wrote on last edited by
          #4

          add this in CMainFrame::OnCreate() : SetWindowPos(NULL, 0,0, 600,350,SWP_NOZORDER|SWP_NOMOVE);

          1 Reply Last reply
          0
          • W will1383

            Hello all, This is a basic question in MFC, but for some odd reason I can't figure out how to do it. I want to be able to specify the size of the main window when it comes up, and would like to be able to save this information (via .ini file I suppose). I thought that by modifying the CreateStruct in the OnCreate or the OnPreCreate would handle this setting the initiail size of the main window, but it does not work. Any suggestions on how to do this, and could anyone point me in the right direction to "save" this window information so when it comes up again I can use the last position/size information. Thank you in advance. Dan

            J Offline
            J Offline
            Jeff Patterson
            wrote on last edited by
            #5

            In addition to S.Rod.'s answer you can also use MoveWindow(200,100,450,300,TRUE); This will change the size and move it around the screen Also, GetClientRect(&rcClient); // get size of client area m_cyClient = rcClient.bottom-rcClient.top; // only the 'y' length Will get the size of the window. To get the left and right sides you can rcClient.Right-rcClien.Right Jeff Patterson Programmers speak in Code. www.anti-dmca.org

            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