0

This may seem that I am asking a silly question to those who already know. Have you ever noticed how hard it is to find these Setting value constants to properties of some MFC control you are just starting to learn. Wouldn't it be nice, if I could just go to some tome of knowledge or because the information is too large to put in a book, then a website where you could drill down to the control and method or property you want to look up to find what setting constants are acceptable...

For example, I am working with a CListCtrl on my CDialog (could even be CDialogEx if needed) and I would like to set the Verticle & Horizontal lines (or gridlines) to this control. You would think I would find an example. So far I haven't. Another one is the CListCtrl Column Format. I found LVCFMT_LEFT, I however am looking for something like "LVCFMT_CENTER" and that isn't it. So I just comb the internet looking to see if I can glimpse my answer from someones question regarding something else on CListCtrl's.

If anyone can guide me on my quest, I would appreciate it.

Maddog

4

1 回答 1

0

Did you look here https://msdn.microsoft.com/en-us/library/hfshke78.aspx ?

To display grid lines you need to set the extended style LVS_EX_GRIDLINES. You do that with a call to SetExtendedStyle.

auto exstyles = m_myListCtrl.GetExtendedStyle();
exstyles |= LVS_EX_HEADERDRAGDROP;
m_myListCtrl.SetExtendedStyle(exstyles);

As for LVCFMT_CENTER, it does work, but not on the first column. See the remarks in MSDN:

If a column is added to a list-view control with index 0 (the leftmost column), it is always LVCFMT_LEFT. Setting other flags on column 0 does not override that alignment. Therefore if you keep inserting columns with index 0, the text in all columns are left-aligned. If you want the first column to be right-aligned or centered you can make a dummy column, then insert one or more columns with index 1 or higher and specify the alignment you require. Finally delete the dummy column.

于 2015-03-06T21:52:05.727 回答