Thread: A special listbox control...

  1. #1
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768

    Question A special listbox control...

    I want to make a list box like the one the one outlook has, with multi-columns, like a column for subject, a column for name.
    That each column stands on it's own, and still attached to the other columns.


    Thanks in advance.
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  2. #2
    Registered User
    Join Date
    May 2003
    Posts
    1,619
    You'll have to make a custom control, because the default Listbox window procedure is inadequate for the task. I'm not at home right now, but when I get there I'll try to look up some references for you.

    Edit: Try looking at this custom controls tutorial:

    http://freespace.virgin.net/james.br...s/custctrl.htm

    The tutorial is decent, but I would recommend you use GetWindowLongPtr/SetWindowLongPtr in place of GetWindowLong/SetWindowLong which are deprecated (they are not compatible with 64 bit architectures while the -Ptr ones are).

    Edit: You'll probably want to use a Header control to work with the columns.
    Last edited by Cat; 05-30-2003 at 04:28 PM.

  3. #3

  4. #4
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768

    Unhappy

    Thank you for your help, but... It's not what I need.

    What I need is listbox with more than one column, so I could make one column for NAME, and the other for NUMBER.
    but when I mark the NAME column, the matcing NUMBER column will be marked as well!

    I know it exists, because many programs use it, like outlook, kazaa, anti-viruses... to specify the name, size, subject or what ever.

    I don't know, maybe it's some sort of a "rich" list control, or something.


    Thanks.
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  5. #5
    Registered User
    Join Date
    May 2003
    Posts
    1,619
    What I said is exactly what you need. I've done something very much like it before (although I'm not sure if I have code from that long ago). The programs you mention use custom controls; many programs do. Essentially, a custom control is just like any other control except you write the window procedure for it, so you have to respond to all messages and draw it. You can make it do anything you want.

    There is no default control that does what you want. You may be able to find someone else's homemade control, or you need to write your own.

    Essentially, the predefined controls (edit boxes, list boxes, buttons, etc.) are all just there for convenience -- you could write any program using only custom controls, but for expediency, a set of predefined controls has been created to make life easier. Nobody wants to reinvent the button every time they write a program, and many/most tasks can be done with the default controls, but the default controls are NOT designed to handle every possible case. And right now, you're trying to do something that no default control can do, so you need to either find a custom control written by someone else, or roll your own.

    The normal controls you're used to are really just controls that have been developed by someone else, and the details hidden from you. In one way, it's great, because it saves you the trouble; on the other hand, it's harmful because a lot of people don't realize the power (and relative simplicity) of a custom control. A custom control can have any behavior that you want.

    The straightforward approach is to make a custom control, which has a standard control embedded within it (a header control). The standard control would draw itself, (once you tell it to invalidate itself as needed) but you'd have to draw the rest of it. The custom control would maintain the list; you should probably emulate the listbox interface very closely for the sake of simplicity.
    Last edited by Cat; 05-30-2003 at 08:48 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. (Multiline) Edit Control Limit
    By P4R4N01D in forum Windows Programming
    Replies: 9
    Last Post: 05-17-2008, 11:56 AM
  2. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  3. Listbox control gridlines?
    By Devil Panther in forum Windows Programming
    Replies: 2
    Last Post: 12-08-2004, 03:43 PM
  4. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  5. Listbox control with horizontal scrollbar
    By Ward in forum Windows Programming
    Replies: 1
    Last Post: 02-06-2002, 10:35 AM