Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Enable selection of any part of line in CListCtrl

Posted on 1998-07-23
9
Medium Priority
?
391 Views
Last Modified: 2008-03-17
I have created a CListCtrl in a report style with single line selection. I have it sorting by multiple columns and it works great except that users can only click on the text of the first column. If you try to click on any part of the line to the right of the first column, nothing gets selected. This stinks because some of my lists have very small (few characters) first columns. It's natural to think you can click anywhere on the line.

I see that Microsoft Outlook does it right, but I don't see any style settings to control this. Anybody got any ideas on how to enable full line selection in a CListCtrl?
0
Comment
Question by:kmenzel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 2

Accepted Solution

by:
lucidity earned 400 total points
ID: 1168476
OverRide the OnLeftMouseDown function for the control. You should be able to get the logical position of the mouse. Then figure out the distance between the entries in the ListCtrl, with that figure out how far in the list the mouse is and SetCurSel to the entry the mouse is over.
0
 
LVL 11

Expert Comment

by:alexo
ID: 1168477
Actually, there is a much simpler answer.

If you use the new common controls (ver 4.72 is freely available from MS but it is sufficient to have IE >=3 installed) you can use the following:

        ListView_SetExtendedListViewStyle(hListView, LVS_EX_FULLROWSELECT);

Of course, that assumes you have the updated header and library files.  If not, get the Inet SDK (freely available from MS).
0
 
LVL 11

Expert Comment

by:alexo
ID: 1168478
I dunno how this would translate to MFC but MFC questions should not be asked here anyway.  There is an "MFC" topic.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:kmenzel
ID: 1168479
That works great and saved me lots of time. Thank you.
0
 
LVL 11

Expert Comment

by:alexo
ID: 1168480
What works great?  Lucidity's answer or my comment?
0
 

Author Comment

by:kmenzel
ID: 1168481
The line
        ListView_SetExtendedListViewStyle(hListView, LVS_EX_FULLROWSELECT);

works great. I did not know that MS had a set of extended styles. I had done many help searchs and looked through 6 books, but did not find this style. But, I sure thought there should be a way to do full row selects. Doesn't make sense not to.

Seems silly that these exetended styles are not incorporated into the regular style base or at least MS should have replaced the older help pages with links to the extended style help pages. I wonder how many other patch type stuff I don't know about because you can't find it unless you already know about it or you use the expert exchange!

Thanks
0
 
LVL 11

Expert Comment

by:alexo
ID: 1168482
>> The line ListView_SetExtendedListViewStyle(...);

So I figured.  Do you realize that you accepted the "OverRide the OnLeftMouseDown" answer instead?  Lucidity got the points because the question was locked by him.


>> Seems silly that these exetended styles are not incorporated into the regular style base

Not silly, just confusing.  You see, they are not really "window styles".  They are flags set and queried by sending appropriate messages to the control (the macro I referred to just does a SendMessage() call).  Therefore you are free to change them at any time, which is not true regarding the "regular style base".

0
 

Author Comment

by:kmenzel
ID: 1168483
No, I did not realize that you did not get the credit. How would I have avoided that. This credit thing is not very straight forward as to how to assign a person credit when a few people have submitted answers. Especially if you don't get a chance to look at an answer until there are multiple answers waiting.

Thanks for clarifing the extended style. Does this mean if my app gets put on a machine without at least ie3.0, the full row select will not work? Even though it was compiled on a machine where it currently works?
0
 
LVL 11

Expert Comment

by:alexo
ID: 1168484
Well, there can only be one pending answer, all the others are considered "comments".  You can "reopen" the question and leave a comment inviting one of those who commented to lock the question instead.

If you'd like to "fix" the situation, you can post a 0-point question in the customer support area (http://www.experts-exchange.com/topics/bin/NewQForm?ta=4) saying that the points for question Q.10066552 should go to <whomever you wish>.

Don't forget to complain LOUDLY that the grading form is very confusing.  It may lead to improvements.

Now, back to the question:

>> the full row select will not work?
Right.  There are ways to overcome it though.

You can test for the installed version of common controls.
    http://www.dejanews.com/getdoc.xp?AN=270672616
    http://www.dejanews.com/getdoc.xp?AN=308663486

You can distribute a new version of common controls with your app.
    http://www.microsoft.com/msdn/downloads/files/40comupd.htm

0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question