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. Resizing a static variable

Resizing a static variable

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
3 Posts 2 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.
  • D Offline
    D Offline
    digwizfox
    wrote on last edited by
    #1

    Here is a description of my problem. I have a modal dialogue window. In my OnInitDialog function, I may have to adjust the size of the window and it's contents manually because sometimes when the dialogue is constructed, an argument is passed into the constructor that turns off the display of certain controls within the window. So when the controls are off, I want to change the size of the window and remaining controls so that everything looks nicer (I don't want a huge blank spot in the middle of the window in this case). So everything was working fine; I tried changing the window size of the dialogue and that worked fine. I know I can move buttons around and adjust them just like you do when a dialogue box is resizable by the user. But how do I resize a static group control? The group box is a border rectangle that surounds the controls and is just inside of the main dialogue. When I run the below bits of code, the GetClientRectangle function causes my system to crash. The group box is a CStatic control which inherits from CWnd. So it must have a rectangle, within the object, to describe it's coordinates. So why does GetClientRect fail? Is this not a valid function call for a CStatic control? If not, how do I get it's coordinates? mGroupBox.GetClientRect(&myRect); //Crash!!! //This would then adjust the height by 25% mGroupBox.SetWindowPos(NULL, 0, 0, myRect.Width(), (myRect.Height() - (myRect.Height()/4)), SWP_NOMOVE | SWP_NOZORDER);

    N 1 Reply Last reply
    0
    • D digwizfox

      Here is a description of my problem. I have a modal dialogue window. In my OnInitDialog function, I may have to adjust the size of the window and it's contents manually because sometimes when the dialogue is constructed, an argument is passed into the constructor that turns off the display of certain controls within the window. So when the controls are off, I want to change the size of the window and remaining controls so that everything looks nicer (I don't want a huge blank spot in the middle of the window in this case). So everything was working fine; I tried changing the window size of the dialogue and that worked fine. I know I can move buttons around and adjust them just like you do when a dialogue box is resizable by the user. But how do I resize a static group control? The group box is a border rectangle that surounds the controls and is just inside of the main dialogue. When I run the below bits of code, the GetClientRectangle function causes my system to crash. The group box is a CStatic control which inherits from CWnd. So it must have a rectangle, within the object, to describe it's coordinates. So why does GetClientRect fail? Is this not a valid function call for a CStatic control? If not, how do I get it's coordinates? mGroupBox.GetClientRect(&myRect); //Crash!!! //This would then adjust the height by 25% mGroupBox.SetWindowPos(NULL, 0, 0, myRect.Width(), (myRect.Height() - (myRect.Height()/4)), SWP_NOMOVE | SWP_NOZORDER);

      N Offline
      N Offline
      namaskaaram
      wrote on last edited by
      #2

      ;)well..... i dontsee anthing wrong..... mGroupBox.GetClientRect(&myRect).....where mGroupBox happenz to be the CStatic Object the "mGroupBox" IS A CWnd type and pointing to the static window(have u given the DDX control??).....once this is done.....use the SetWindowPos function(i have not used this,but i think maybe U HAVENT LINKED THE VARIABLE TO THE WINDOW USIND DDX maybe thatzthe prob)..... best of luck..... happy programmin...... cheerz..... :-D

      D 1 Reply Last reply
      0
      • N namaskaaram

        ;)well..... i dontsee anthing wrong..... mGroupBox.GetClientRect(&myRect).....where mGroupBox happenz to be the CStatic Object the "mGroupBox" IS A CWnd type and pointing to the static window(have u given the DDX control??).....once this is done.....use the SetWindowPos function(i have not used this,but i think maybe U HAVENT LINKED THE VARIABLE TO THE WINDOW USIND DDX maybe thatzthe prob)..... best of luck..... happy programmin...... cheerz..... :-D

        D Offline
        D Offline
        digwizfox
        wrote on last edited by
        #3

        The problem was that I was trying to implement the aforementioned code in my OnInitDialog method, prior to calling CDialog::OnInitDialog like so BOOL UDxFilterDlg::OnInitDialog() { //NO! NO! Can't do this here. Must call //CDialog::OnInitDialog(); first! CRect rect; mGroupBox.GetClientRect(&rect); mGroupBox.SetWindowPos(NULL, 0, 0, rect.Width(), (rect.Height() - (rect.Height()/3)), SWP_NOMOVE | SWP_NOZORDER); CDialog::OnInitDialog(); //Resize the group box below this point and it works fine! //..rest of code }

        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