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 CListCtrl

Resizing CListCtrl

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionlearning
6 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.
  • G Offline
    G Offline
    grassrootkit
    wrote on last edited by
    #1

    I'm handling ::OnSize() of my CView and I want my CListCtrl resize accordingly .

    void CMyView::OnSize(UINT nType, int cx, int cy)
    {
    RECT rc;
    //this->GetWindowRect(&rc);
    POINT p;
    p.x = cx;
    p.y = cy;
    //ClientToScreen(&p);
    GetClientRect(&rc);
    // m_cMyList.SetWindowPos(NULL,0,0,rc.cx,cy,1);
    m_cMyList.SetWindowPos(NULL,0,0,rc.right,rc.bottom,1);

    }

    As you see I tried out damn things [Of course the wrong way!]. Nothing works. Any help?

    S 1 Reply Last reply
    0
    • G grassrootkit

      I'm handling ::OnSize() of my CView and I want my CListCtrl resize accordingly .

      void CMyView::OnSize(UINT nType, int cx, int cy)
      {
      RECT rc;
      //this->GetWindowRect(&rc);
      POINT p;
      p.x = cx;
      p.y = cy;
      //ClientToScreen(&p);
      GetClientRect(&rc);
      // m_cMyList.SetWindowPos(NULL,0,0,rc.cx,cy,1);
      m_cMyList.SetWindowPos(NULL,0,0,rc.right,rc.bottom,1);

      }

      As you see I tried out damn things [Of course the wrong way!]. Nothing works. Any help?

      S Offline
      S Offline
      SandipG
      wrote on last edited by
      #2

      Check SetWindowPos[^] documentation.

      grassrootkit wrote:

      m_cMyList.SetWindowPos(NULL,0,0,rc.right,rc.bottom,1);

      Here instead of NULL you should specify &CWnd::wndTop because it seems that it is the only control on your dialog. Also last parameter instead of 1 pass SWP_SHOWWINDOW i am not sure 1 is defined for which constant.

      grassrootkit wrote:

      GetClientRect(&rc);

      You do not need this instead you can use cx,cy parameters. I think you doing this because first time when you get the WM_SIZE notification these values are zero. You can simply put a check for that instead of that call. Also when you resizing the window in OnSize always verify the m_cMylist has valid handle and it is visible. This should be done because WM_SIZE notification is sent multiple times when the main window is being created. I hope it helps.

      Regards, Sandip.

      G C 2 Replies Last reply
      0
      • S SandipG

        Check SetWindowPos[^] documentation.

        grassrootkit wrote:

        m_cMyList.SetWindowPos(NULL,0,0,rc.right,rc.bottom,1);

        Here instead of NULL you should specify &CWnd::wndTop because it seems that it is the only control on your dialog. Also last parameter instead of 1 pass SWP_SHOWWINDOW i am not sure 1 is defined for which constant.

        grassrootkit wrote:

        GetClientRect(&rc);

        You do not need this instead you can use cx,cy parameters. I think you doing this because first time when you get the WM_SIZE notification these values are zero. You can simply put a check for that instead of that call. Also when you resizing the window in OnSize always verify the m_cMylist has valid handle and it is visible. This should be done because WM_SIZE notification is sent multiple times when the main window is being created. I hope it helps.

        Regards, Sandip.

        G Offline
        G Offline
        grassrootkit
        wrote on last edited by
        #3

        SandipG wrote:

        SWP_SHOWWINDOW

        Does the matter. I put 1 just to quickly test the functionality. What a crap. This wasted almost half an hour. Thanks for pointing it out.:thumbsup:

        1 Reply Last reply
        0
        • S SandipG

          Check SetWindowPos[^] documentation.

          grassrootkit wrote:

          m_cMyList.SetWindowPos(NULL,0,0,rc.right,rc.bottom,1);

          Here instead of NULL you should specify &CWnd::wndTop because it seems that it is the only control on your dialog. Also last parameter instead of 1 pass SWP_SHOWWINDOW i am not sure 1 is defined for which constant.

          grassrootkit wrote:

          GetClientRect(&rc);

          You do not need this instead you can use cx,cy parameters. I think you doing this because first time when you get the WM_SIZE notification these values are zero. You can simply put a check for that instead of that call. Also when you resizing the window in OnSize always verify the m_cMylist has valid handle and it is visible. This should be done because WM_SIZE notification is sent multiple times when the main window is being created. I hope it helps.

          Regards, Sandip.

          C Offline
          C Offline
          Code o mat
          wrote on last edited by
          #4

          Actually he may specify NULL as the first parameter and use the SWP_NOZORDER flag to indicate he doesn't wish to change the Z-order of the window...

          > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

          S 1 Reply Last reply
          0
          • C Code o mat

            Actually he may specify NULL as the first parameter and use the SWP_NOZORDER flag to indicate he doesn't wish to change the Z-order of the window...

            > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

            S Offline
            S Offline
            SandipG
            wrote on last edited by
            #5

            Yes.. i forgot about the SWP_NOZORDER :)

            Regards, Sandip.

            C 1 Reply Last reply
            0
            • S SandipG

              Yes.. i forgot about the SWP_NOZORDER :)

              Regards, Sandip.

              C Offline
              C Offline
              Code o mat
              wrote on last edited by
              #6

              Being forgetful is a common...erm...what's it called...umm...sympthom by programmers, because...umm...erm...what were we talking about again? :D

              > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

              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