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 group box control during runtime

resizing a group box control during runtime

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
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.
  • S Offline
    S Offline
    SWDevil
    wrote on last edited by
    #1

    I would like to resize a group box control during run-time (for instance in the OnInitDialog function). I only need to change it's height (make it smaller). How can I do this? I tried the following (which didn't work..): CRect rect; GetDlgItem(IDC_STATIC_GRP_SEARCH)->GetClientRect(rect); rect.SetRect(11,280,66,280); rect.DeflateRect(0,0,0,rect.Height()-50); SetRect did not work so I tried using DeflateRect - and that also did not work. Please help...

    M A S 3 Replies Last reply
    0
    • S SWDevil

      I would like to resize a group box control during run-time (for instance in the OnInitDialog function). I only need to change it's height (make it smaller). How can I do this? I tried the following (which didn't work..): CRect rect; GetDlgItem(IDC_STATIC_GRP_SEARCH)->GetClientRect(rect); rect.SetRect(11,280,66,280); rect.DeflateRect(0,0,0,rect.Height()-50); SetRect did not work so I tried using DeflateRect - and that also did not work. Please help...

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      You're changing a RECT, but you still need to change the size of the control. SetWindowPos() will do that.

      --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ Dunder-Mifflin, this is Pam.

      1 Reply Last reply
      0
      • S SWDevil

        I would like to resize a group box control during run-time (for instance in the OnInitDialog function). I only need to change it's height (make it smaller). How can I do this? I tried the following (which didn't work..): CRect rect; GetDlgItem(IDC_STATIC_GRP_SEARCH)->GetClientRect(rect); rect.SetRect(11,280,66,280); rect.DeflateRect(0,0,0,rect.Height()-50); SetRect did not work so I tried using DeflateRect - and that also did not work. Please help...

        A Offline
        A Offline
        Arman S
        wrote on last edited by
        #3

        Then set the modified rect back to the control. Use either of; SetWindowPos MoveWindow

        -- ===== Arman

        1 Reply Last reply
        0
        • S SWDevil

          I would like to resize a group box control during run-time (for instance in the OnInitDialog function). I only need to change it's height (make it smaller). How can I do this? I tried the following (which didn't work..): CRect rect; GetDlgItem(IDC_STATIC_GRP_SEARCH)->GetClientRect(rect); rect.SetRect(11,280,66,280); rect.DeflateRect(0,0,0,rect.Height()-50); SetRect did not work so I tried using DeflateRect - and that also did not work. Please help...

          S Offline
          S Offline
          SWDevil
          wrote on last edited by
          #4

          I don't understand - do I have to call setRect and afterwards call setWindowPos or MoveWindow, or do I not need to call setRect? I tried adding a call to setWindowPos as following: CRect rect; GetDlgItem(IDC_STATIC_GRP_SEARCH)->GetClientRect(rect); rect.SetRect(11,280,66,280); MoveWindow(11,280,198,66); but it just ends up changing the size of the whole dialog and not the control itself.... if you could please write an example of the code it would be very helpful.

          A 1 Reply Last reply
          0
          • S SWDevil

            I don't understand - do I have to call setRect and afterwards call setWindowPos or MoveWindow, or do I not need to call setRect? I tried adding a call to setWindowPos as following: CRect rect; GetDlgItem(IDC_STATIC_GRP_SEARCH)->GetClientRect(rect); rect.SetRect(11,280,66,280); MoveWindow(11,280,198,66); but it just ends up changing the size of the whole dialog and not the control itself.... if you could please write an example of the code it would be very helpful.

            A Offline
            A Offline
            Arman S
            wrote on last edited by
            #5

            Even no need to the get the client rect in your case; this is because you specify absolute coordinates; I mean not depending on the current position of the control.

            //CRect rect;
            //GetDlgItem(IDC_STATIC_GRP_SEARCH)->GetClientRect(rect);
            //rect.SetRect(11,280,66,280);

            GetDlgItem(IDC_STATIC_GRP_SEARCH)->MoveWindow(11,280,198,66);

            -- ===== Arman

            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