How do you remove focus from a listbox manually?
-
Hello, This is my problem: I have a list box which is used to select a certain item via double-click. This item can then be placed on a map. The problem is, while placing the item, the mousewheel has functionality within the program other than scrolling the list box. I need this mousewheel functionality to work, but once the item in the list box is selected, the focus stays on the list box and the mousewheel will only scroll the list and not do what I want it to do within the main program window. If I could just move the focus from the list box to some other button, or remove it entirely, (without actually clicking on another list or button) the problem should be solved. I have tried: SendMessage(list_box,LBN_KILLFOCUS,0,0); SendMessage(list_box,WM_KILLFOCUS,0,0); where list_box is the handle of my list box, but, both of those KILLFOCUS messages are returns rather than messages that can be sent to the handle and processed. I just need some way to get the focus off of the darned list box... Thanks for your help, Kelly
-
Hello, This is my problem: I have a list box which is used to select a certain item via double-click. This item can then be placed on a map. The problem is, while placing the item, the mousewheel has functionality within the program other than scrolling the list box. I need this mousewheel functionality to work, but once the item in the list box is selected, the focus stays on the list box and the mousewheel will only scroll the list and not do what I want it to do within the main program window. If I could just move the focus from the list box to some other button, or remove it entirely, (without actually clicking on another list or button) the problem should be solved. I have tried: SendMessage(list_box,LBN_KILLFOCUS,0,0); SendMessage(list_box,WM_KILLFOCUS,0,0); where list_box is the handle of my list box, but, both of those KILLFOCUS messages are returns rather than messages that can be sent to the handle and processed. I just need some way to get the focus off of the darned list box... Thanks for your help, Kelly
i was in your case before. i did lots test, result is: no way to do that. my solution is: create a Static control (Static has no focus on), then draw strings on the control - it is quite hard because you need to draw scroll-bar also. when user click the static control, you know which string is selected, then do something according to the string. but, maybe someone knows easy solution, i hope see it via your post. includeh10
-
Hello, This is my problem: I have a list box which is used to select a certain item via double-click. This item can then be placed on a map. The problem is, while placing the item, the mousewheel has functionality within the program other than scrolling the list box. I need this mousewheel functionality to work, but once the item in the list box is selected, the focus stays on the list box and the mousewheel will only scroll the list and not do what I want it to do within the main program window. If I could just move the focus from the list box to some other button, or remove it entirely, (without actually clicking on another list or button) the problem should be solved. I have tried: SendMessage(list_box,LBN_KILLFOCUS,0,0); SendMessage(list_box,WM_KILLFOCUS,0,0); where list_box is the handle of my list box, but, both of those KILLFOCUS messages are returns rather than messages that can be sent to the handle and processed. I just need some way to get the focus off of the darned list box... Thanks for your help, Kelly
Hi, I once had a similiar problem within a tree control. My solution was to make a boolean variable (bDoubleClicked) which was initially set to false. When the user double clicked an item I just set this variable to true and remembered what he/she choosed. My actual action was taken on the mouse button up message. By looking if the user had double clicked I performed the task. In any case bDoubleClicked was set to false again. The problem was that the mouse action was bound to the tree control and not released until the button up message arrived to that control. I think you should use this method for your problem too. Hope this helps. Regards G. Steudtel
-
Hello, This is my problem: I have a list box which is used to select a certain item via double-click. This item can then be placed on a map. The problem is, while placing the item, the mousewheel has functionality within the program other than scrolling the list box. I need this mousewheel functionality to work, but once the item in the list box is selected, the focus stays on the list box and the mousewheel will only scroll the list and not do what I want it to do within the main program window. If I could just move the focus from the list box to some other button, or remove it entirely, (without actually clicking on another list or button) the problem should be solved. I have tried: SendMessage(list_box,LBN_KILLFOCUS,0,0); SendMessage(list_box,WM_KILLFOCUS,0,0); where list_box is the handle of my list box, but, both of those KILLFOCUS messages are returns rather than messages that can be sent to the handle and processed. I just need some way to get the focus off of the darned list box... Thanks for your help, Kelly
After the item in the listbox has been double-clicked, why can't you just call
SetFocus()
to set the focus on the "map" control?
Five birds are sitting on a fence. Three of them decide to fly off. How many are left?
-
Hi, I once had a similiar problem within a tree control. My solution was to make a boolean variable (bDoubleClicked) which was initially set to false. When the user double clicked an item I just set this variable to true and remembered what he/she choosed. My actual action was taken on the mouse button up message. By looking if the user had double clicked I performed the task. In any case bDoubleClicked was set to false again. The problem was that the mouse action was bound to the tree control and not released until the button up message arrived to that control. I think you should use this method for your problem too. Hope this helps. Regards G. Steudtel
Thank you for the suggestion, but I think it probably won't work - the problem is, once the mouse clicks onto the list box, that's it, the focus is now on the list box. I need some way to remove the focus from the list box. Regardless of what variables I use to save position and such, once the mouse clicks even once on the list box, that's it, problem activated. I'd really rather not manually write a list box, I've done that in other portions of the code that involve larger bitmaps and such and it's a pain to always keep track of where they are in relation to the larger window etc, if I'm going to do that I'll just throw in an extra button instead that you're forced to click in order to place the selected items, but that's such a hassle for the user.. I can't imagine that there isn't some way to simply send a message to a window to change or remove focus.. it seems like such a basic function? Thanks for the suggestions though guys, hopefully there is some way to do this.. Kelly
-
After the item in the listbox has been double-clicked, why can't you just call
SetFocus()
to set the focus on the "map" control?
Five birds are sitting on a fence. Three of them decide to fly off. How many are left?
-
I didn't realize there was a SetFocus function - Thank you, that's exactly what I was asking, I just tried it and it works the way I want :)
if you have scroll-bar in listbox, i don't think things are so simple, especially need to manage keyboad-input. visual c++ prompt window (appears if type dot after an object) is an example which doesn't use normal listbox. includeh10
-
if you have scroll-bar in listbox, i don't think things are so simple, especially need to manage keyboad-input. visual c++ prompt window (appears if type dot after an object) is an example which doesn't use normal listbox. includeh10
A scrollbar does not affect a listbox's ability to set/kill focus.
Five birds are sitting on a fence. Three of them decide to fly off. How many are left?