?
Solved

Enable selection of any part of line in CListCtrl

Posted on 1998-07-23
9
Medium Priority
?
386 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses
Course of the Month9 days, 16 hours left to enroll

762 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