How to add data Filtering using CListCtrl and CHeaderCtrl - mfc

Background:
Applications that manipulate a collection of data typically present using a grid containing a header. These same applications typically incorporate a filter to allow the user to narrow the data set (Excel is a wonderful example. There are many others).
In my MFC application, I'm attempting to do the same using the CListCtrl and CHeaderCtrl combination. This combination has already enabled my application to provide for multiple column sorting including using the Image capabilities of the individual header items to represent ascending/descending sort order.
I have used my best Google-fu to locate any examples where the CHeaderCtrl was extended/customized to include custom drawing to account for the addition of the filter button and display an associated drop menu for user input of filter criteria when clicked.
Question(s):
Are there examples I missed?
If no examples available via the internet, what approach(es) should I consider in customizing CListCtrl and CHeaderCtrl to accomplish my goal?
Additional Comments:
One of the answers referenced the built-in FilterBar functionality. Yes I've seen that but it's not what I'm looking for. I'm looking to specifically emulate the non-static, non-visually intrusive filtering capabilities of Excel and other filter-enabled applications.

My Google-fu confirms yours, no examples that add non-invasive filter interface to CListCtrl, with or without the CHeaderCtrl.
Simple approach
In your HDN_ITEMCLICK handler, check the ((NMHEADER)lParam).iButton. For iButton == 1, that's the right mouse button. Here's your chance to show a little CWnd-dervied filter UI. Problem with this approach is there's no visual indication that right-click will bring up a filter menu.
More complicated
Create three column header images - filter icon, up arrow + filter icon, down arrow + filter icon. When not sorted on a column, show the filter only image, otherwise use the appropriate arrow + filter image. Handle click on the CListCtrl at the NM_RCLICK level so you get coordinate info (example.) Do some geometry to figure out if the click was on your filter icon, if so, show a little CWnd-derived filter UI. You can get even fancier and show the current filter in header tooltips, create more images with colored filters to show when a filter is active.

Is this you are looking for?
Since it is in other language, I have given the googled address. Refer second result.

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.

Is it possible to write a simple custom link that shows or hides all layers on a page?

I have a draw.io diagram page consisting of over 40 layers. But because I don't know which layers the user will have hidden/shown on the published diagram, I want to provide a button with an action set that hides all layers, then shows 3 specific layers.
Is it possible to hide all layers using a wildcard or similar, or do I need to manually create a huge (in manual management terms) layer id JSON array?
From what I can tell it's not possible, which surprises me, hence my asking. For my diagram it means I need to maintain huge JSON arrays in many links.
I've tried various custom links using cell and tag action wildcards, but my tests suggest tags only work for shapes (not layers), and cells includes both shapes AND layers.
data:action/json,{"actions":[{"hide":{"cells":["*"]}}]}
I hoped using the above custom link would cause all layers to be hidden, which it did, but it also caused shapes on the currently selected layer to be hidden. It also caused shapes on the currently selected layer to appear deleted within the editor, so I needed to use the Undo feature to get the shapes back. I guess this is a bug, unless I'm doing something wrong or my drawing has become corrupt.
Something like this would be a really useful feature:
data:action/json,{"actions":[{"hide":{"layers":["*"]}}]}
I would consider writing a plugin, but can't find any help documentation on the subject. Could someone advise on this?
It is possible to add tags to a layer. In order to do this, edit layer data (click on the layer, then on the three vertical dots) and add the "tags" property:
Add "tags" property to layer
Afterwards, you'll be able to add a tag to the layer like this:
Add tag "some_tag" to the layer
Now you can show or hide all layers with the tag some_tag with the following custom links:
Show all layers with some_tag:
data:action/json,{"actions":[{"show":{"tags":["some_tag"]}}]}
Hide all layers with some_tag:
data:action/json,{"actions":[{"hide":{"tags":["some_tag"]}}]}
I worked around the problem of not being able to hide all layers on a page via wildcard by using tags.
It's possible to tag individual shapes, or by grouping shapes and adding the tags property at the group level. So long as a shape or group has a "tags" property in the "Edit Data" screen with a value in it, it's possible to hide all by using the following custom link:
data:action/json,{"actions":[{"hide":{"tags":[""]}}]}
The same for showing all tags on a page:
data:action/json,{"actions":[{"show":{"tags":[""]}}]}
To show everything on a page without using tags it's possible to just use:
data:action/json,{"actions":[{"show":{"cells":["*"]}}]}
I also needed to add two buttons to an admin layer:
A "reset" button with "hide"/"show" custom link actions to reset the diagram to an initial state.
A "show all" button with "show" custom link actions to get all the shapes visible again, otherwise it wasn't possible to access them when editing the diagram.

Disable only specific list items in a win32 ListView

I am using win32, c++.
I have a ListView & i want to disable (grey out) only some of the items from the list.
Is that possible or only whole ListView can be greyed out?
The ListView control does not have a concept of disabled items. You can simulate that appearance using custom drawing support. This Sample demonstrates how to change the text and background color of items within the list view.
You would need to go further and provide some means of determining when a disabled item is selected within the view (as the selection will continue to work).
The Windows List View Common Control does not have a disabled state for Items. If you want to do that, you will have to implement it yourself.
This is a not-trivial exercise. It's not hard to change the visible appearance using customer draw, but handling hit-testing and selection would be quite complex.

How do you get a list picker like the kind shown in the alarm clock?

How do you create the big, scrolling list picker, like the kind that is created for datePicker and timePicker which is used on the WP7 default alarm clock? The remaining list pickers don't have quite the same effect. I would be using the list pickers only to choose integer values.
Thanks
The DatePicker and TimePicker are controls that are provided by the Silverlight Toolkit for WP7. What they actually do is present the selection in one control in your page, then navigate to a separate page that allows you to actually select a new date/time. In these separate pages they use a collection of LoopingSelector controls (one per item) that enable the user to select the parts of the date/time.
If you want to display a similar picker but for numeric values, then you need to implement the same infrstructure but using a single LoopingSelector and you need to provide the correct data source (that implements the ILoopingSelectorDataSource interface) that specifies the values for your control.
There is a great series of 3 posts on the LoopingSelector on WindowsPhoneGeek.com

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