I am trying to create a complicated MFC tree control that has the edit and combobox control capabilities that this tutorial has. However, I found that this sample is not flexible enough to actually use.
1) The one combobox example initializes the box with hard coded strings and cannot be used for more than one box in the tree.
2) The placement of the initialization of the data in the DoDataExchange function doesn't make sense to me. I don't want the entire control to have to reinitialize everything every time there is a UdateData call.
3) I could not add the combobox and edit items as children, because there is no InsertItem function that will take an image index and the handle to the parent.
4) The image indexes are all hard coded, as is the resource ID of the actual tree.bmp file for the icons. It would take modifications to make this work as a more flexible class that could be used for more than one tree control in a project.
Now, in all fairness, my understanding of MFC is still rudimentary. I am impressed with the author's ability to even write this. I did learn some things from this sample.
I would be much more impressed if this class could be used to support more than one type of tree control.
I would like to use CTreeOptionsCtrl in a splitter window in a Doc/View app.
The MFC CTreeCtrl is created automatically and accessed through CTreeView::GetTreeCtrl(), how do I get a CTreeOptionsCtrl created instead?
Tick-boxes ungray themselves if I change their state, I have fixed the problem mainly by moving all the bitmaps up by one, and some fixes to the code. anywone want it, just mail me. I am mailing it to author:JP Naughter.
I did not like the "edit-box" and combo-box mechanism, and instead put the edit control just below the tree, with a prompt, this is less messy, since the edit-box sometimes appears chopped off if the tree is wide, + the tree's own tooltip gets in the way!!!
I also have a problem with parent window notification, but worked around it in a nasty way, using sendmessage to the control parent since the parent dialog never got the TVN_SELCHANGED, and I wanted it in the parent, messy way to do lots of NOTIFY messages. MFC is at fault this time I know.
Conrad - firstname.lastname@example.org
Always do badly to start off, that way when you get the hang of it suddenly, everyone is surprised.
I'd suggest you pull down the latest version from my web site at www.naughter.com as there has been numerous updates since I posted this article to codeproject (27 updates in fact since it was posted on codeproject).
I'd check the return value from the functions: LoadIcon, CImageList::Add, SetImageList and InsertItem. I'd also suggest that your create a bitmap resource and use that as your image list. See the sample app for how this is done. Also don't forget to pull down the latest version from my web site at www.naugter.com.
Hi there. I am looking to be able to load the contents of combo boxes at runtime. For example, in our code when we want to populate a combo box, we fill in a vector of strings and pass it to the GUI code, which then adds them.. (Our GUI is localized; there are two versions of everything: "external" for the GUI, "internal" to be stored internally. We also use plugins, where the available settings from plugin to plugin might be different.)
How hard would it be to rewrite/adapt the code (assuming I do it) to make this possible? One method that comes to mind would be to change the code so that rather than store a class type in the dialog data, we store an abstract id, that can be resolved to a class type plus a specific instance of that class, which we could invoke to add strings directly (using an extended interface)..
To add strings at runtime to a combo box just use CComboBox::AddString. If you mean in combination with my TreeOptionsctrl, then look at the sample which comes with it, specifically the "CDowComboBox" class.
As regards localisation, all the strings which the class uses are taken from string table resources, so you should just need to translate these.
Last Visit: 31-Dec-99 18:00 Last Update: 10-Jul-14 13:12