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. Cannot size window using STARTUPINFO

Cannot size window using STARTUPINFO

Scheduled Pinned Locked Moved C / C++ / MFC
question
7 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

    I would like my newly window to open up with the given sizes. The following code maximizes the window when it gets created. Why doesn't it work? Thanks! STARTUPINFO stStartUpInfo; PROCESS_INFORMATION pProcessInfo; memset(&stStartUpInfo, 0, sizeof(STARTUPINFO)); stStartUpInfo.cb = sizeof(STARTUPINFO); stStartUpInfo.dwFlags = STARTF_USESIZE; CreateProcess(NULL, CmdLine, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &stStartUpInfo, &pProcessInfo);

    S R 2 Replies Last reply
    0
    • E elephantstar

      I would like my newly window to open up with the given sizes. The following code maximizes the window when it gets created. Why doesn't it work? Thanks! STARTUPINFO stStartUpInfo; PROCESS_INFORMATION pProcessInfo; memset(&stStartUpInfo, 0, sizeof(STARTUPINFO)); stStartUpInfo.cb = sizeof(STARTUPINFO); stStartUpInfo.dwFlags = STARTF_USESIZE; CreateProcess(NULL, CmdLine, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &stStartUpInfo, &pProcessInfo);

      S Offline
      S Offline
      Stephen Hewitt
      wrote on last edited by
      #2

      Look like the following is missing: stStartUpInfo.wShowWindow = SW_MAXIMIZE; Your code looks like it would show the window hidden as it memsets the struct to zero and 0 is SW_HIDE. Steve

      E 1 Reply Last reply
      0
      • S Stephen Hewitt

        Look like the following is missing: stStartUpInfo.wShowWindow = SW_MAXIMIZE; Your code looks like it would show the window hidden as it memsets the struct to zero and 0 is SW_HIDE. Steve

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

        The window does show up but it's maximized. That's not what I want. I want the window size to be set to what I defined for dwXSize and dwYSize .

        S 1 Reply Last reply
        0
        • E elephantstar

          The window does show up but it's maximized. That's not what I want. I want the window size to be set to what I defined for dwXSize and dwYSize .

          S Offline
          S Offline
          Stephen Hewitt
          wrote on last edited by
          #4

          Try this:

          STARTUPINFO si;
          ZeroMemory(&si, sizeof(si));
          si.cb sizeof(si);
          si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USEPOSITION | STARTF_USESIZE;
          si.wShowWindow = SW_SHOWNORMAL;
          si.dwX = 0;
          si.dwY = 0;
          si.dwXSize = 100;
          si.dwYSize = 100;
          

          Steve

          E 1 Reply Last reply
          0
          • E elephantstar

            I would like my newly window to open up with the given sizes. The following code maximizes the window when it gets created. Why doesn't it work? Thanks! STARTUPINFO stStartUpInfo; PROCESS_INFORMATION pProcessInfo; memset(&stStartUpInfo, 0, sizeof(STARTUPINFO)); stStartUpInfo.cb = sizeof(STARTUPINFO); stStartUpInfo.dwFlags = STARTF_USESIZE; CreateProcess(NULL, CmdLine, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &stStartUpInfo, &pProcessInfo);

            R Offline
            R Offline
            Ryan Binns
            wrote on last edited by
            #5

            An application is free to ignore the values in the STARTUPINFO structure if it wants to.

            Ryan

            "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

            1 Reply Last reply
            0
            • S Stephen Hewitt

              Try this:

              STARTUPINFO si;
              ZeroMemory(&si, sizeof(si));
              si.cb sizeof(si);
              si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USEPOSITION | STARTF_USESIZE;
              si.wShowWindow = SW_SHOWNORMAL;
              si.dwX = 0;
              si.dwY = 0;
              si.dwXSize = 100;
              si.dwYSize = 100;
              

              Steve

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

              It still maximizes the window. Ryan (below) mentioned that application can ignore the STARTUPINFO struct if it wants to. So is there no way around this?

              S 1 Reply Last reply
              0
              • E elephantstar

                It still maximizes the window. Ryan (below) mentioned that application can ignore the STARTUPINFO struct if it wants to. So is there no way around this?

                S Offline
                S Offline
                Stephen Hewitt
                wrote on last edited by
                #7

                Before I started to look for ways around it I would verify the code with notepad (an application that respects it, I think) or something. I can't think of any easy way around it. You could install a WM_CBT hook with the SetWindowsHookEx API but this would involve setting a global hook (and thus creating a DLL and taking care that it doesn't crash or effect other applications). Steve

                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