CListCtrl

...a couple little questions regarding manipulating CListCtrl objects...

the first one: alignment of column headers and its contents is controled through LVCFMT_LEFT, _RIGHT, and _CENTER... i have four columns and three are fine but the first one is aligned to the left regardless of my settings and there is no way to change it... what could it be?

the second one: is there a way to set a "row height" for a list? i mean to change the vertical distance between items of the list because they're quite tightly placed by default and it's not very easy to see them...
LVL 21
YurichAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

northernchillCommented:
I can't answer your first question, but this link should answer the second.

http://www.codeguru.com/listview/change_row_height.shtml
0
jackrabbit22Commented:
1)  I've found the alignment will work if you update the alignment for the column AFTER you've inserted column:

The following will center align the first column:

     LPCTSTR lpszColTitles[3] = {_T("First Name"), _T("Last Name"), _T("City")};

     for (int nCol = 0; nCol < 3; nCol++)
     {
                // Insert new column
          m_listCtrl.InsertColumn(nCol, lpszColTitles[nCol], LVCFMT_LEFT, 120);

                // Now update it's alignment
          LVCOLUMN lvc;
          ::ZeroMemory(&lvc, sizeof(LVCOLUMN));
          lvc.mask = LVCF_FMT;
          lvc.fmt = LVCFMT_CENTER;
          m_listCtrl.SetColumn(nCol, &lvc);
     }
     
     m_listCtrl.InsertItem(0, _T("Joe"));
     m_listCtrl.InsertItem(0, _T("Harry"));
     m_listCtrl.InsertItem(0, _T("Reggie"));

2)  For changing item height, I override the OnMeasureItem function in the CListCtrl's parent class:

void CMyDialog::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
     // Set the item height our list control
    if (nIDCtl == IDC_MY_LISTCTRL)
        lpMeasureItemStruct->itemHeight = 18;
     
     CDialog::OnMeasureItem(nIDCtl, lpMeasureItemStruct);
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
YurichAuthor Commented:
...neither of suggestions would work for row height because my list resides in the dialog box and in this case WM_MEASUREITEM is not processed at all... all sizes are predefined during creation of the list in dialog box editor... yet, the first part works just fine, thanks...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.