Listbox stealing focus

This is a discussion on Listbox stealing focus within the Windows Programming forums, part of the Platform Specific Boards category; I'm working on a small drawing app which adds all the items drawn in my drawing window to a listbox ...

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    10

    Listbox stealing focus

    I'm working on a small drawing app which adds all the items drawn in my drawing window to a listbox as strings.
    I also have a couple of buttons in order to select different drawing tools.

    My main window needs keyboad input focus to be able to handle shift and ctrl keypresses.

    At first I only had the buttons and no listbox, so after any button was pressed I simply called SetFocus(mainWnd) after i processed WM_COMMAND.

    This didn't work as well with the listbox since none of the selections got marked if I called SetFocus(mainWnd) directly after the listbox was clicked on.

    Will I have to subclass the listbox and pass it's keyboard messages to my main window in order for everything to work as intended or is there another solution ?
    Using : MSVS .NET 2003
    OS : Windows XP

  2. #2
    Registered User
    Join Date
    Feb 2002
    Posts
    329
    I don't know about listboxes, but in listviews, there's a parameter called hideselection(i think, not at my computer).
    This keeps the item selection when the list loses focus..

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    3
    u have no idea to set focus back to main dialog (if u force to do that, the list box doesn't work well).

    if u use Visual C++, u can see a listbox on its prompt window (about functions and fields of a class), it looks like a listbox, but actually it is not - it is an user control (creted by VC developer).

    if u really need the listbox, you have to draw it yourself - a few days with high programming skills.

    when u draw it, do not use any windows common control on it, draw everything (scrollbar etc) by DC.

  4. #4
    Registered User
    Join Date
    Nov 2002
    Posts
    10
    Thanks, guess I'll look into listview
    Using : MSVS .NET 2003
    OS : Windows XP

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. cant load dialog with listbox, help
    By terracota in forum Windows Programming
    Replies: 2
    Last Post: 11-22-2004, 06:11 PM
  2. How to cast a ListBox item to an int for a switch statment?
    By Swaine777 in forum C++ Programming
    Replies: 8
    Last Post: 09-26-2004, 08:52 PM
  3. Compiler Stealing Focus
    By quizkiwi in forum C++ Programming
    Replies: 2
    Last Post: 08-31-2004, 09:37 AM
  4. Focus & Always-On-Top :: MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 06-13-2002, 05:44 PM
  5. Getting FULL filename from listbox
    By Garfield in forum Windows Programming
    Replies: 8
    Last Post: 01-27-2002, 07:28 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21