Link to home
Start Free TrialLog in
Avatar of sidney091097
sidney091097

asked on

CListCtrl Report Style Row Height

I want to be able to set the row height of a CListCtrl in Report stlye.  The column width can be easily set, but I can not find access to the height attribute.

I would prefer to use CustomDraw instead of using setting the owner drawn attribute.  Besides, I don't think this effects a list in Report style anyway.  

I just want wider rows with the rest of the default behavior as is.

How do I do this?
Avatar of MT_MU
MT_MU

I suspect the easiest way is to change the font.

Assuming you are using this in a dialog, do something like the following in OnInitialUpdate()


CFont* pFont = m_List.GetFont(); // get the current font
LOGFONT logfont;
pFont->GetLogFont(&logfont);  // and it's characteristics - for me this returns lfHeight = -11;

logfont.lfHeight = -14;  // set a new height

m_NewFont = new CFont;  // create a new font
m_NewFont->CreateFontIndirect(&logfont); // with the appro characteristics
m_List.SetFont(m_NewFont); // and tell the list control to use it
Avatar of sidney091097

ASKER

This works except that in order to get the height I want, I have to use a font that is too big.  In addition, this effects the font of the header title which I do not want.

Thanks anyway,
Cindy
This works except that in order to get the height I want, I have to use a font that is too big.  In addition, this effects the font of the header title which I do not want.

Thanks anyway,
Cindy
> I just want wider rows

Er, do you want wider rows, or taller rows?

..B ekiM
Maybe you can change the image's size stored in your imagelist.


    m_LargeImageList.Create(sizex,sizey,ILC_COLOR24|ILC_MASK,10,1000);
    ListCtrl.SetImageList(&m_LargeImageList, LVSIL_SMALL);



Good Luck!
> change the image's size stored in your imagelist.

If you have memory to burn, I guess that's a good idea.  An image list, even when metpy, is going to use some memory based on the size of the bitmaps you've indicated you will record in it. Manipulating the image list to change the height of rows is wasteful.

..B ekiM
First, I would like to set the row HEIGHT.  Sorry for the confusion.

Second, I don't think changing the size of the bitmap is a good solution.

There's got to be a way of getting to this attribute.  CCtrlList inherits from CWnd, but I'm not sure how to handle these subitems.

ASKER CERTIFIED SOLUTION
Avatar of mikeblas
mikeblas

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You can take the DrawItem() code from ROWLIST sample.

But for changing the height of the row, simply handle WM_MEASUREITEM. Change lpMeasureItemStruct->itemHeight to the height you require.

If you don't find the message in the ClassWizard add it yourself. Add this line before END_MESSAGE_MAP() in the cpp file:
ON_WM_MEASUREITEM_REFLECT()

In the .h file add the following line just before DECLARE_MESSAGE_MAP():
afx_msg void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);

Vicky