How to select a folder from a listbox? (C++, WinAPI) - c++

I've seen answers for this all over the place but not for non-MFC C++. I already know how to populate a listbox with the contents of a folder - that's not what I want. I need a listbox to have a small folder picker so I can display the contents of the selected item (the files therein) in a separate list box. Again, I know how to achieve all of this except for having a folder picker inside a listbox.
I've looked at all the listbox functions on MSDN and there was only like four or five functions there and none of them seem to do this.
I don't really have any relevant code to post related to this question, so I hope what I have explained here is good enough.
Here's a picture of what I'm trying to replicate:
Thanks!

Related

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.

How can I add Windows right click context menu items?

I am trying to add new actions to the right click context menu when you select a file or many files. I am writing a program in C++ which contains the functionality that I want to trigger.
As far as I know I have to add new entries to the registers when installing my program and also, I have to use COM(here I got completely lost).
Is there a straightforward way of doing this?
As already suggested by #Igor Tandetnik you can do almost everything you want with Registry entries.
https://msdn.microsoft.com/en-us/library/windows/desktop/cc144169.aspx

Is there a way to have multiple columns in a QMenu?

Is there a way to have multiple columns in a QMenu? I'm using Qt with C++. I have searched and there does not seem to be a way to do this built in to Qt. The question then is how do I add this functionality to my program? Has anyone built a custom menu that can have multiple columns?
Maybe a submenu is what you're looking for. As qt doc says:
Separators are inserted with addSeparator(), submenus with addMenu(), and all other items are considered action items.
For example, here there is a full example. And "Format" menu item is a submenu. You can add a submenu with:
m_mysubmenu = QMenu(...);
...
m_menu->addMenu(m_mysubmenu);
I found a way to do this here. This is not normally something that you want to do; there is usually a better way; but in my application, the user will be greatly helped by it.

How to create combobox with images in Gtk?

Can anyone please tell me how to create a combobox like following with Gtk (on Linux)? (I already ask this question for win32 API).
A code example or tutorial will be very helpful. I have tried searching this over the internet, but unfortunately documentations/tutorials aren't that much rich for Gtk. Thank you very much.
Regards,
I know how to do this in C, but I'll try to wing it in C++. First of all, use a ComboBox to display your menu, which you will fill using a TreeModel.
Create a TreeModelColumnRecord following the example here; you will need just one Gdk::Pixbuf column to display your line images.
Pass the TreeModelColumnRecord to the constructor of ListStore. Fill your ListStore with Gdk::Pixbuf images of your line patterns, and pass that to the constructor of your ComboBox (ListStore inherits from TreeModel).

How can I visually design a component in C++ Builder?

I have been away from C++ for a couple of years now doing AS3/Flex work. I have gotten used to being able to create a component and place it in design mode with very little fuss and I am struggling to get my head around the C++ Builder way of doing the same thing.
I have written many components for C++ Builder in the past, but none of them have been visual. What I would like to do now is create a component for customer search and another for order processing because I want to be able to create a new instance of these on the fly. What I don't want to do is have to place each of the components like the dbgrid and search fields manually in code. I would like to do this (as well as set their properties) in design mode.
How do I go about this? I have browsed the source for other Delphi components and I notice they have dfm files which seems to be what I need. How do I do this in C++ Builder? The only option I see is to add a new form if I want a dfm, but this isn't what I want as my components will be based on TPanel.
Is there a way to do this or do I have to resort to doing it all in code with no visual reference?
Pursuing the DFM idea I did a test this morning where I created a component based on TPanel and added a new form to it which I create and parent in the constructor of the component. In design mode I set the form border to none and placed a grid on it. This all looks OK until I place the component in my application, at that point it looks like a panel with a standard looking form in it and the grid is missing. If I run the app the panel shows as expected, borderless and with a grid. The DFM appears to be ignored in design mode for some reason.
If you know a better way to do this than using components then please give me some pointers.
Any help and advice will be appreciated beyond words
You might want to have a look at frames (look for "Frame objects"). They are "subforms" you can design visually and then place on forms.
Just as an FYI item, you can also drop the panel on a form, put any other controls on it, position them, set captions, etc..
Now, click the panel to select it, and use Component->Create Component Template from the IDE's main menu. This creates a unit you can install as a component which will add the panel and it's sub-controls (as a single component) to the IDE's component palette.
Of course, you can then modify the source for that new component like any other component source.