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

Michael Murdock
  • 129
  • 1
  • 9

1 Answers1

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.

Marius Bancila
  • 16,053
  • 9
  • 49
  • 91
  • That is the weirdest thing ever. So it's not a requirement of the control or a design decision that the first column is left aligned, it's a limitation of the adding function that it overwrites the property arbitrarily for the first one. Weird! – Blindy Mar 06 '15 at 21:57
  • I believe it's one of those bugs that became a feature over time (because changing it would have broken things). – Marius Bancila Mar 06 '15 at 21:59
  • Thanks for answering my question with such alacrity and to the point. The link at the top however didn't give any info on the constants themselves like `LVCF_`anything. I did find intellisense helps a little by giving me others if I already have one such value setting as in `LVCF_LEFT` for example. What I am searching (not sure if available) is to find all such values for all such properties of all such controls of all such classes within MFC. That would be awesome! Thanks again. – Michael Murdock Mar 06 '15 at 22:11