Ownerdrawn CBS_DROPDOWN ComboBox in ListView issue

Started by fearless, October 13, 2011, 04:09:57 PM

Previous topic - Next topic

fearless

Hi,

Been working on code from in place editing of listview subitems (Donkey's example - http://www.masm32.com/board/index.php?topic=1955.0) and whilst the code works fine for CBS_DROPDOWNLIST, it doesnt show up when i change style to CBS_DROPDOWN.

Ideally i want to provide user with an option of either typing in a value in the combo or picking from a dropdown list that provides some values. Once returned the list item should then show either the picked combobox item or the custom text the user entered. Also all in uppercase.

I done some searching on google and the forums here and found some examples of subclassing the combo box using GetComboBoxInfo to get handle for the edit control portion of the combo (http://www.masm32.com/board/index.php?topic=2449.0), but as its ownerdrawn and inside the listview item im not sure how to modify my code to take this into account. Ive seen sublassing for edit controls and can figure out how to force to uppercase, its just the combo wont show with CBS_DROPDOWN. Here is my full list of code that works with CBS_DROPDOWNLIST, does anyone have any pointers on how i change the code to show the CBS_DROPDOWN and handle the edit control portion? Thanks in advance.

:)
ƒearless

fearless

Solved this one.

As the dropdown combo box is made up of a list, and editbox and a combo, i needed to subclass the editbox portion and handle losing focus.

Most of my code is based on examples i found - Donkey's TestListView and Japeth's EditLV (http://www.japheth.de/Download/Samples/EditLV.zip)

Ive added all the code required into a listview.asm file - include this and then see the example on how to add numerous amounts of either types of comboboxes at runtime for in place editing of listview items.

Couple of issues i found - LVM_GETSUBITEMRECT doesnt work for iSubItem = 0 (as in the first column in a listview) so i manually calc this by getting column width. Also hit testing for first column does not work correctly - it will only work if you click on the text in the item in the first column - to fix this you can set extended style of listview to fullrowselect which seems to solve the issue - the example has this in place already.

I changed the coding around WM_KILLFOCUS from the above examples to better handle the CBS_DROPDOWN combo - all is explained in the source code - but basically if you dont account for the consituent parts of the CBS_DROPDOWN combo (list, combo and editbox) if you just destroy the combo once it has lost focus (focus lost to the edit box or list portion for example) it will never work - so instead we ignore that request if focus is being lost to the list or edit portion of our combo - problem solved - i hope.

CBN_SELCHANGE is used to change the listview items text. Ive adding some code so that if a user presses ESC then the original text value is replaced. Otherwise if a user moves away from the combo or preses RETURN it is left as it was changed (havent accounted for text change in the Editbox of the dropdown combo unless return is pressed - on the todo list :D )

Also, has some issues getting ownerdrawn working for the CBS_DROPDOWN combo - so left code commented out, maybe someone else can figure that out - its a small niggle and doesnt look to bad without it anyhow i think.

Anyways have a look at the example and hopefully it will help others (LVCombo.zip include the RadASM project - listviewcomboexample1.zip is just the image attached to this post)

ƒearless


xandaz

   Fearless.... i'm having a hard time getting the edit control to get the focus.... i subclassed all and even changed the edit control style but nothing.

fearless

Can you paste or attach your example to see where the problem lies, or is the focus issue from the demo i made? Thanks
ƒearless

xandaz

    Sorry for the late reply.... i'm pasting the example but there's a lot of mud. I was trying lots of stuff but it's simple enough for you to make it work without getting lost. Thanks a lot fearless.

xandaz

    Ooops..... sorry about that guys. i was using CBS_DROPDOWNLIST instead of ..._DROPDOWN or _SIMPLE. Couldnt write to the edit Control. :green