-
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 ?
-
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..
-
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.
-
Thanks, guess I'll look into listview :)