CTreeCtrl - only use checkboxes for certain rows/children - c++

I have a CTreeCtrl and I filled it with content. Now I wanted to add checkboxes but JUST for certain ones. I've found the possibilty to activate checkboxes on the TreeCtrl with m_Tree.ModifyStyle(0, TVS_CHECKBOXES), but this adds a checkbox on each node/child on the whole Ctrl. Is it possible to turn this feature on, but just for certain ones?
All I found is the possibility to add three different pictures, catch the clickevent on a node and change the image. Is there an easier way? Let me know.
Thanks a lot,
jntme

I don't think that CTreeCtrl provide any method to add check boxes at specified node only.
Easiest way to do this is explain in following link.
http://www.tech-archive.net/Archive/VC/microsoft.public.vc.mfc/2005-10/msg00454.html.
please go through and let me know if you are facing problem.

You may be able to accomplish what you want with a custom draw tree control. But, you'll need to render the image states yourself. That could get messy because you'll need to account for all of the possible different states.

Related

Menu designed for use without mouse. What is the best way to implement?

I'm writing a GUI using QT for embedded system with linux. This device has no mouse. Only display and specific keyboard with keys: up, down, return and 7 number keys.
The software will be used to set some parameters of device and read them (some charts also).
Example of how menu could look:
after OPTION 1 selected
After SUBOPTION 1 selected some table with data is loaded.
Sometimes after selecting option i need to load specific widget and sometimes just another set of options.
I think it is possible to implement custom labels and kind of list widget that aligns them.
I guess it is also possible to use Qt's MVC classes for it. They are highly customizable, but i never made custom views and delegates.
Maybe i just need to create QtListView with stringlist model and apply stylesheet to it so it gets look more like buttons. And based on selection in list load next widget.
Which way is better and why?
Is there any easier ways to accomplish this?
Any ideas would be appreciated.

How can I sort Items in `CListCtrl` when the button is clicked?

How can I sort Items in CListCtrl when the button is clicked?
I made a Dialog based application in MFC.
I put CListCtrl control on my Dialog and set its view style to report type.
I have two columns in this list view.
In here when I clicked the "Sorting" button, it should sort item in the list.
I saw many examples related to this, but none is working for me.
Can some one guide me how to do that?
I assume that you mean the column header when you write "sorting button".
You probably forgot to put this into the message map of your dialog:
ON_NOTIFY(LVN_COLUMNCLICK, IDC_LIST1, OnColumnclickList1)
IDC_LIST1 is the id of the list control which may be different in your code.
Are you somewhat familiar with MFC ? If not, you should follow one of the numerous tutorials available on the net.
I would use a CMFCListCtrl. It is easier, as it as built in sorting functionality and you only have to provide a function with the comparing items algorithm for sorting. I have succeeded using it. You have to override the OnCompareItems on your class derived from CMFCListCtrl. I also recommend you to do a call to EnableMarkSortedColumn(); after your list is created.
The CListCtrl has a SortItems method.
All you need to do is provide your Compare function to it as the parameter.
I don't know much about the contents of your list control so I can't really give you more information.
Please read up on it and extend your question with example code and details of which column needs to be sorted and I can help more.
If the contents of your cells are just text then I usually just return the value of:
return Value1.CollateNoCase(Value2);
There are also lots of tutorials on the Internet. For example:
http://www.codeproject.com/Articles/27774/CListCtrl-and-sorting-rows
In fact, that tutorial suggests us in SortItemsEx. That is what I would use.

Possible for ListCtrl Colspan, or similar functionality?

Is there a way to have a ListCtrl cell span several columns? Or perhaps to able to append a panel / other element to a ListCtrl item that will contain the info I need?
No. The ListCtrl does not support that functionality. There is a pure Python list control widget called the UltimateListCtrl that allows you add any widget to a cell, although it doesn't appear to allow cell spanning either. I would still try this widget and see if it works for you. If it does not, you may be able to patch it yourself because it's written in Python or you could do a feature request for it to be added to the UltimateListCtrl on the wxPython mailing list and see if anyone takes you up on it.
You can do spanning in a wx.Grid widget if you wanted to go that route, although it's pretty limited when it comes to embedding other widgets.

Customizing CMFCRibbonBar im MFC

I am trying to customize the default MFC RibbonBar. I need to reduce its height, change its color etc, but so far i haven't found anything on how to do so. I've been to msdn, and they just tell you how to add new controls on the ribbon.Can any one please point me in the right direction? Is this ribbon control even customize-able? i mean apart from adding categories and other controls on it, i want to change the look of the ribbon.
Some code samples about how to work with MFCRibbonControl would be of great help too.

Does MFC have a built in grid control?

First what I want: The ability to display a grid with multiple columns, each cell having a custom render callback. So you might use such a control to display your inventory in a game, or something like the behaviour in Google Chrome where it shows a grid of popular pages you visit.
I've been playing with CListCtrl and while I can get custom rendering ability on each item, I can't get it work with columns - having say 3 items per row. The control has column-related methods but I think these are specifically for the built-in functionality where different attributes of an item are shown automatically in each column... not for providing a generic grid control.
So, does such functionality exist in MFC? If not then I wonder if the easiest approach is for me to actually insert each of the rows as an Item... and then the custom rendering draws the multiple cells in the row, I could also do custom UI to support clicking on the cells.
But what I really want is to be able to create a custom control, and add this as an item to a list - like in Flex for instance - so I/O etc is automatically handled.
Any advice/information welcome...
Dundas has thrown some of its (excellent) components in the public domain. Their Ultimate Grid is available on CodeProject.
I'm not aware of a built-in control, but I think you should take a look at this.
The article is describing in detail the functionality of a fully featured MFC grid control, derived from CWnd, for displaying tabular data.
YOUR_LIST_CONTROL.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_INFOTIP|LVS_EX_GRIDLINES);
I think it will help you (SetExtendedStyle).
I suggest this one:
https://code.google.com/p/cgridlistctrlex/
very complete