I'm not sure if this is the appropriate place to put it, as my question is regarding C++, but for OWL rather than MFC. Anyways, down to the problem:
I'm maintaining some legacy code which involves a multi-line listbox. The contents of this listbox are loaded in through the EvDrawItem function. The EvDrawItem gets called repeatedly. While selecting an object, the cells in the listbox are selected one at a time too, and we are manually painting it in (not sure if this is the right way to do it). This becomes noticeable only when the items are long.
Now, here's the biggest part of the problem: when double-clicking on an item, we are supposed to pop up an edit box. While this does happen, the double-clicking is seen to cause the item to do cycles of "select, select, de-select, select"...about 50 (each cycle is made up of 4 EvDrawItems) times (is this normal???).
With some research, I do feel that I should probably make use of the setredraw and invalidate functions, but I'm not sure where's the best place to put these codes in so that they propagate through the rest of the program where similar listboxes are used.
Also, since the draw and the insertions are handled together, would suppressing redraw affect how the list loads up?
Thank you for your response. Yes, I've already looked at that, and I do feel it would help, just trying to find the best place to put it. However, I'm still not sure why it does the "select, select, deselect, select" thing so many times on a double-click. I would suspect it's not a normal behaviour even without disabling the redraw.
Upon further investigation, it turns out that the child control is receiving messages asking it to traverse through all the lines in the selected item. For each of the lines, it receives the following itemAction and itemState (in this order):
1. ODA_SELECT with ODS_SELECTED
2. ODA_FOCUS with ODS_DEFAULT | ODS_SELECTED
3. ODA_FOCUS with ODS_SELECTED
4. ODA_SELECT with 0
Unfortunately, events 1 and 4 cause the program to select/deselect all the rows in the multi-row item, which results in huge flickering. Fortunately, our redraw function does nothing on events 2 and 3 . So right now, my question is:
1. Is this traversing of all the items something that was implemented in the TListBox base class or are we telling it to do that somewhere in our code?
2. Also, is it better to override this traversing to do one big redraw or to override the handling to only select, deselect, then re-select each row?
Your question is not really clear because if there is only one item in the dropdown area, the vertical scrollbar is not displayed. You probably mean that you have several items available in the dropdown but only one is visible at a time ? And you would like to increase that so that multiple items are visible at the same time right ?
Well, you can correct that through the resource editor: when you select the combo box, click on the part where the arrow is situated, this will let you adjust the height of the dropdown area, and not the size of the control itself.
Well, if there is only one item in your combo box, there's no scrollbar. Why would you need a scrollbar, there's nothing to scroll.
Did you understand my reply at least ? Is that what you were looking for of not ? Did you try it ?
Well, did you try what I suggested ? Increasing the size of the dropdown area ?
By default only one item is visible at a time but you have to increase the height of the dropdown area in order to make multiple elements visible (which will of course also increase the height of the scrollbar if any).
You really should try the suggestions that are given to you before replying...
Luc Pattyn [Forum Guidelines][Why QA sucks][My Articles] I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
Last Visit: 29-Oct-20 10:05 Last Update: 29-Oct-20 10:05