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 control.

Resizing a control.

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++helplearning
6 Posts 4 Posters 1 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.
  • N Offline
    N Offline
    NullStream
    wrote on last edited by
    #1

    This is a simple question though I can't seem to figure out the 'right way' of doing it. I have a dialog window with only a listbox and a titlebar. What is the best approach to make the listbox fill the entire window (with room for the title bar as well)? I'm using just a simple dialog and listbox resource and am not using MFC so I'm assuming there some message sending that will need to be done. Any information or even just a poke in the right direction would help. Sean

    C A 2 Replies Last reply
    0
    • N NullStream

      This is a simple question though I can't seem to figure out the 'right way' of doing it. I have a dialog window with only a listbox and a titlebar. What is the best approach to make the listbox fill the entire window (with room for the title bar as well)? I'm using just a simple dialog and listbox resource and am not using MFC so I'm assuming there some message sending that will need to be done. Any information or even just a poke in the right direction would help. Sean

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Use GetCLientRect to find out the size of the Window and MoveWindow or SetWindowPos to resize the control. Christian I have come to clean zee pooollll. - Michael Martin Dec 30, 2001 Picture the daffodil. And while you do that, I'll be over here going through your stuff. Picture a world without war, without hate. And I can picture us attacking that world, because they would never expect it.

      Sonork ID 100.10002:MeanManOz

      I live in Bob's HungOut now

      N 1 Reply Last reply
      0
      • C Christian Graus

        Use GetCLientRect to find out the size of the Window and MoveWindow or SetWindowPos to resize the control. Christian I have come to clean zee pooollll. - Michael Martin Dec 30, 2001 Picture the daffodil. And while you do that, I'll be over here going through your stuff. Picture a world without war, without hate. And I can picture us attacking that world, because they would never expect it.

        Sonork ID 100.10002:MeanManOz

        I live in Bob's HungOut now

        N Offline
        N Offline
        NullStream
        wrote on last edited by
        #3

        Will GetCLientRect return the size of the ENTIRE window or the window-toolbar (aka the client area)? I'm assuming I have to do this on WM_RESIZE as well? Sean

        C R 2 Replies Last reply
        0
        • N NullStream

          Will GetCLientRect return the size of the ENTIRE window or the window-toolbar (aka the client area)? I'm assuming I have to do this on WM_RESIZE as well? Sean

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          It will return the rect of the client area, the area WM_PAINT can draw on. GetWindowRect will return the whole window, in screen co-ordinates. It's GetClientRect too, I made a typo... Christian I have come to clean zee pooollll. - Michael Martin Dec 30, 2001 Picture the daffodil. And while you do that, I'll be over here going through your stuff. Picture a world without war, without hate. And I can picture us attacking that world, because they would never expect it.

          Sonork ID 100.10002:MeanManOz

          I live in Bob's HungOut now

          1 Reply Last reply
          0
          • N NullStream

            Will GetCLientRect return the size of the ENTIRE window or the window-toolbar (aka the client area)? I'm assuming I have to do this on WM_RESIZE as well? Sean

            R Offline
            R Offline
            Ravi Bhavnani
            wrote on last edited by
            #5

            No. Just handle the WM_SIZE.

            CListBox* pListBox = (ClistBox *) GetDlgItem (IDC_LIST_BOX);
            if (pListBox != NULL) {
            CRect clientRect;
            GetClientRect (&clientRect);
            pListBox->MoveWindow (&clientRect);
            }

            /ravi "There is always one more bug..." http://www.ravib.com ravib@ravib.com

            1 Reply Last reply
            0
            • N NullStream

              This is a simple question though I can't seem to figure out the 'right way' of doing it. I have a dialog window with only a listbox and a titlebar. What is the best approach to make the listbox fill the entire window (with room for the title bar as well)? I'm using just a simple dialog and listbox resource and am not using MFC so I'm assuming there some message sending that will need to be done. Any information or even just a poke in the right direction would help. Sean

              A Offline
              A Offline
              alex barylski
              wrote on last edited by
              #6

              LRESULT CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
              {
              RECT rect; //Holds client rectangle coordinates
              HWND hList; //Handle to listbox

              //Retrieve coordinates of client rect
              GetClientRect(hDlg, &rect);

              switch(uMsg)
              {
              case WM_SIZE:
              hList = GetDlgItem(hDlg, IDC_MYLIST);
              MoveWindow(hList, rect.left, rect.top, rect.right, rect.bottom, TRUE);
              break;
              }
              }

              Hope i didn't forget anything...:) "An expert is someone who has made all the mistakes in thier field" - Niels Bohr

              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