[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 246
  • Last Modified:

TCheckListBox -

I am using a TCheckListBox with style lbOwnerDrawFixed. It displays drives with little pictures depending on the type of drive. It works great except that when the user clicks on the text/picture it draws a rectangle around it (sort of like to show the focus). I don't like it. I would like either one of the two following behaviours:

1 - when they click on the text/picture, behave as if the checkbox itself had been clicked and without the rectangle(my first choice)

2 - at least not get the rectangle.
0
sharons
Asked:
sharons
  • 2
  • 2
1 Solution
 
ZifNabCommented:
sharons, why then don't you just use TListBox or TCombobox with lbOwnerDrawFixed? ZiF.

0
 
sharonsAuthor Commented:
I do need the check boxes. I use this for the user to select the drives to be made available at a kiosk. This is part of the setup process.  Sorry if I was not clear.
0
 
atzeCommented:
why don't you use TListBox and a TImageList? Get the images you need and do the changes of the checkbox by your owne that's all.
0
 
sharonsAuthor Commented:
Sorry, I don't understand your solution. Here is exacly what I do:

When users first use my program, they have to select one or many drives. So I loop from a to z and see which letters are valid drive. So I add an item in the TCheckListBox (with style lbOwnerDrawFixed). For each item I draw a little image and the drive letter. And of course the actual chack box is there beside each item (which is what I need). The user then checks all the desired drives. I then create a string with all the drive letters Ex: ACD and saves that to the registry.

My problem is that if the user clicks on the text or image (instead of the little check box) then one or more item gets a rectangle drawn around it as if it had the focus. This looks bad and this is what I want to get rid of. I do need the check boxes so why would I use a TListBox ? Maybe I am missing your point.

You can test what I mean by dropping a TCheckListBox on a form. Add a few items then click on the text. Whatever happens to the text is what I want to eliminate. It might just draw one rectangle at the time (I just realize that when I said rectangle you might have though I was talking about the checkbox itself, I am talking about a "Focus rectangle").
0
 
atzeCommented:
You don't have to use TTreeView but if you don't like the Focusrectangle around your pictures this is one possible solution

Add a TTreeNode for every Drive and set the ImageIndex to the right Image in the ImageList (a checked and an unchecked checkbox in the ImageList plus your Drive images). You can now change the Image in the TreeView by changing the ImageIndex of the TreeNode.


0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now