Resizing CListCtrl
-
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?
-
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?
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.
-
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.
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:
-
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.
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. <
-
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. <
-
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. <