|
-
October 18th, 2009, 09:47 AM
#1
Auto Resizing CListCtrl columns as Dialog is resized
Hi,
I have a CListCtrl with 2 columns. Right now the CListCtrl expands and shrinks as the dialog is resized, however the columns do not resize, what i am trying to do is to divide the width of the CListCtrl equally among the 2 columns. I have tried using SetColumnWidth without much luck, heres the code:
Code:
CRect rect;
int newWidth;
if(m_pList->GetSafeHwnd())
{
m_pList->GetWindowRect(rect);
ScreenToClient(rect);
newWidth = (rect.right-rect.left)/2;
rect.right = rect.left + cx - 20;
m_pList->SetColumnWidth(0,newWidth);
m_pList->SetColumnWidth(1,newWidth);
m_pList->MoveWindow(rect);
}
how can this be done?
Thanks
-
October 18th, 2009, 10:50 AM
#2
Re: Auto Resizing CListCtrl columns as Dialog is resized
A couple of notes:
1. Is this called in the OnSize handler for your dialog?
2. You might need to call m_pList->MoveWindow(rect) before calling the SetColumnWidth on the columns (I just looked at working code and I call it before).
3. Instead of GetWindowRect() and ScreenToClient, just call GetClientRect(). It will more accurately represent the size for your control, and does the coordinate conversion internally.
-
October 22nd, 2009, 07:12 AM
#3
Re: Auto Resizing CListCtrl columns as Dialog is resized
hi,
thanks for your response, sorry about my taking so long to post back. I just got around to fixing this, Its fixed.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|