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.
I want to be able to reuse CDowComboBox for two completely different combo boxes, each with different available settings. So imagine I add a parameter to the constructor (or whereever), passing a vector of strings, which would then be consumed in the Create() function to build the combo box content. Can this be done?
Bonus question: How would I completely clear out the strings from an existing combo box, and readd different strings? (Some controls filter the content displayed in other controls.)
Note that the CTreeOptionsCombo object would be owned by the caller, not by the CTreeOptionsCtrl. At the moment, this blows up because the CTreeOptionsCtrl is still expecting to create the object. It would be best if I could take ownership of the object, though, so I can invoke the normal MFC combo box API when I need to. (To add or remove strings, change the selection, change the drop width, etc.)
Perhaps instead of this: m_ctrlTree.AddComboBox(HTREEITEM, myCombo1.GetRuntimeClass());
do this instead (after the necessary changes, of course)? m_ctrlTree.AddComboBox(HTREEITEM, &myCombo1);
int CDowComboBox::OnCreate(LPCREATESTRUCT lpCreateStruct)
//Let the base class do its thing
if (CListOptionsCombo::OnCreate(lpCreateStruct) == -1)
//Get the ListOptionsCtrl item data
CListOptionsItemData* pItemData = (CListOptionsItemData*)m_pListCtrl->GetItemData(m_nListCtrlIndex);
//Cast this controls item data back to a CStringArray
CStringArray* pNames = (CStringArray*)pItemData->m_dwItemData;
for (int nIndex = 0; nIndex < pNames->GetSize(); nIndex++)
Bonus Question Answer: If you use the above mechanism then whenever you change what is in "some_stack_based_CStringArray" somewhere else in your code, then these changes will be reflected into the combo box when it is recreated.
I'm not sure this is a very useful addition. It's definitely a non - standard UI and IMHO would confuse end users. You are free of course to derive your own class from mine and modify it to suit your means.
I use your source in my project,but compile failure,the cause is "LNK erro can
not open file 'mfc42u.lib'",I do not know in your source where the mfc42u.lib is
used, I look into msdn ,but can not find it.
Sorry but I think you are incorrect on this. As I have already pointed out, you need to do a custom install of VC 6 to get the Unicode MFC libraries installed. It has nothing to do with the version of OS service pack or compiler service pack you have installed.
I tried to extend the control for supporting multiline editboxes. There is a structure called TVITEMEX. I used iIntegral to increase the height of the items. This height is in increments of the standard item height (see TVM_SETITEMHEIGHT). By default, each item gets one increment of item height. Setting this member to 2 will give the item twice the standard height; setting this member to 3 will give the item three times the standard height; and so on. So far so good. The trouble is that scrolling of the tree don't works well any more. Has anybody an idea? T hanx.
Instead of trying it this way, why did use the existing support for edit boxes and instead specify ES_MULTILINE and ensure the edit box is created with the height you want. Just like the way normal drop down combos work.
The idea is that the text (contents) of the edit box should appear as item label in the tree after destroying the box by losing the focus. But there is too few space between the items for more than one row of text. In a combo box you select only one row. Therefore it isn't a problem to draw the text selected as item in the tree.
When you have multiple levels of checkboxes, and change the state of a checkbox, the state is updated only for the immediately parent and the childs of this checkbox.
This update should be completely recursive.
I've made the changes for my needs, and for the moment, I don't have enough time to post it.
If someone wants the code to do that, please mail me.
Yes I would,I have fixed a different bug, and encountered the same need to be able to gray out an entire branch in one call.
I fixed a problem where graying a tick-box, and then turning it on/off was ungraying it. I consequently fixed a couple of errors in that regard.
I also have a problem with parent window notification, but worked around it in a nasty way, using senmessage to the control parent since the parent dialog never got the TVN_SELCHANGED, and I wanted it in the parent, ....how do I get it to echo? did U fix this?
I want to post my fix all-together to JP Naughter, since I am currently working on this all.
Conrad - email@example.com
Always do badly to start off, that way when you get the hang of it suddenly, everyone is surprised.
Well, you can put an image before every control or after. To do that, I've modified the original bitmap which contains 16*16 icons. Now, each icon is 32*16. I simply have added a blank 16*16 icon to the right of each icon.
Then, I've build another bitmap with other symbols one the same way, but now, the blank icon is on the left. You have also to add both bitmap to an imagelist.
So when you create an item in the tree, you assign an icon of the first or the second bitmap, and then set an overlay image for this item. This overlay image must be an image where the blank portion is on the opposite side of the main image.
dont know if this is the right place or not but now ill try it out anyway.. ;o)
well i need some open asp code without "dll" or "com"/"active x" if possible that can show or draw organisation chart based on a employee table.
the chart should dynamically show employee / department-structure in a tree view and/or box(kinda)diagram.
The tableshould use ID and "ChildID" / "parentID" for structuring the chart.
I am developing a project that includes a Dialog containing a CTreeCtrl object.
When running my application in a WindowsNT machine and i display the Dialog i can see correctly the CTreeCtrl.
But when i run my application in a Windows98 machine when i display the Dialog if i don´t click on the CTreeCtrl i can´t see it.
I have seen during the execution of my application that when i display the dialog that contains the CTreeCtrl, what is selected (or focused) is the dialog and not the CTreeCtrl.
If i don't click on in the CTreeCtrl twice it doesn't appear and at this moment it is selected (focused).
But this case is only produced the first time i open the dialog.The following times i open the dialog, the CTreeCtrl is displayed correctly.
In my resource.h file i have the following definition:
IDD_TREE DIALOGEX 0, 0, 662, 402
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
FONT 8, "MS Sans Serif"
CONTROL "Tree1",IDC_TREE,"SysTreeView32",TVS_HASLINES |
TVS_LINESATROOT | TVS_DISABLEDRAGDROP |
TVS_SHOWSELALWAYS | TVS_NOTOOLTIPS | TVS_INFOTIP | WS_BORDER | WS_GROUP | WS_TABSTOP,5,5,650,350,
The first time i open the dialog, as caption property (on the top) of the tree, i can see "Tree1" and when i click on it twice it disappears.
Thanks in advance