Using ListControl in a Dialog window - c++

Can ListControl be used in a dialog in a Non-MFC project? I am using visual c++ 2010.
The examples I have seen so far uses MFC, so it seems to me that ListControl is part of MFC. The code I am working on is not MFC based, however, Visual Studio still allows adding a ListControl to the dialog in the resource view, and generates rc code for the List Control. So my guess is that I should be able to use it. However, I could not use the standard method found online to add variable to the ListControl and use it.
How can I use the ListControl in this case? e.g. adding a column or write something to a cell? Some code example will certainly help.

The CListCtrl class is an MFC class. It can only be used from within an MFC project.
However, CListCtrl is simply a wrapper around the ListView common control, and a ListView control can be used in any Windows application—no MFC required.
The Resource Editor included with Visual C++ (confusingly) refers to a ListView control as a "List Control". You can insert one on your dialog, and all it will do is insert a ListView control.
If you're using MFC, you can choose to create a member variable corresponding to that control. The type of that member variable will be CListCtrl, because it is encapsulating access to a ListView control on your dialog.
If you are not using MFC, you can still use the ListView control, you'll just have to use the standard SDK mechanisms for accessing and manipulating it. For example, to insert an item into the ListView control on your dialog, you would obtain the control's window handle (GetDlgCtrlID) and send it a LVM_INSERTITEM message. The SDK documentation contains sample code listings, but they are a rather poor way to learn. The best resource for good old Windows SDK programming is still Charles Petzold's Programming Windows.

Related

How to use MFC ListCtrl in SDI

I am really a beginner with MFC. I just want a few guidelines on how to use a ListCtrl in an SDI application. For example, getting input from the user and displaying it in the listctrl when a button is clicked. Please guide me.
In SDI application I would use CListView-derived class for main view. This class has been designed to be used in SDI/MDI apps and supports standard MFC document-view architecture. The CListView class internally uses CListCtrl, but it does automatic resizing and other handy things, you can also get direct access to embedded list ctrl by calling CListView::GetListCtrl() method that returns CListCtrl*.

Feature-installation style tree control in C++ with MFC

With reference to this installer control:
My question is: is this dropdown-button style tree control available to use for other purposes within an MFC application?
My suspicion (after inspecting with Spy++) is that it is a heavily customised SysTreeView32, using wide icons that look like buttons, and that mouse-clicks on these icons are intercepted to display dropdown menus.
Does anyone know any better?

using SHAutoComplete with CEdit control

I am developing an MFC application, can i use SHAutoComplete with a CEdit control? Also is there any ready made auto complete controls are available? or i need to use write all the code for creating the list box below the edit control as user types in edit control?
Just pass CEdit's m_hwnd member to SHAutoComplete. I don't think that extension warrant another class. The listbox is created by the AutoComplete object created by SHAutoComplete.
SHAutoComplete helps to autocomplete paths (system or URL).
If this is a combo box and you want to use autocomplete for suggesting string contained in the combo, you have to write a code to handle it.
There are samples you can find. One I found (working):
http://www.ucancode.net/Visual_C_MFC_COM_faq/Visual-C-Auto-completion-ComboBox-CComboBox.htm

Embedding file open dialog

Office 2010 has a new type of ribbon, the backstage view. This has been implemented in MFC using Codejock Xtreme Toolkit Pro V15.0.1.
The thing is that I feel that the File>Open and File>SaveAs act very strange in Office. They open a modal file open dialog instead of opening an embedded file open dialog in the backstage, which would (IMHO) feel much more natural.
I cannot find a way of doing this in C++ using MFC or Win32. The only thing I found was this question, but that was for Delphi.
So, is it possible to embed the standard Windows File Open dialog as a control in another dialog? Or do I need to implement the entire thing myself?
To the best of my knowledge, The standard Open/Save dialog functionality is exposed through the modal dialog only (through the GetOpenFilename Win32 API).
There is a standard mechanisme to customise the dialog (See Skizz answer) but it remains a modal dialog. One case of advanced customisation was the VB6 Open Project dialog:
The Existing tab contains a file dialog. How did they do it? I mean, how did they manage to put a standard dialog into a page of their 3-tabs property sheet?
It appears that they simply used the standard customization dialog and added a tab control above the standard dir/file controls and listview for other 'tabs' above dir/file controls. These dir/file controls were then hidden by the custom code when a tab other than Existing was clicked. You get it: no real tabs! Just a good old file dialog where the main controls may be hidden in favor of other ones.
So my short answer is: You're pretty much out of luck using the dialog as a child control.
Now, to come back to Office: I believe it's better to keep a modal dialog. It would otherwise be confusing to user: Is the path that I started to type the real path of did I just clicked 'Home' and let the save command unfinished?
I don't know if you can embed a file open dialog into another dialog, but you can certainly extend the existing dialogs:-
Here's one implementation.
And another.
And an MSDN version.
Thanks to David for pointing out the above are a bit out of date, so, after a quick Google, here's a more modern take on extending the file dialogs (and lots of other stuff as well).

Controls on main window using Visual C++ designer?

Is is possible to draw controls using Visual C++ designer on the main window, in the same way you can design dialogs? I'd preferably like to be able to design the main window controls this way without using MFC, rather than creating them on WM_CREATE.
EDIT: I don't want a dialog-based app, just to be able to design the main window graphically similar to what can be done using Windows Forms Designer in .NET?
Your options are:
Use MFC and create a main window that has a dialog view (based on the CFormView class).
Use WinForms/.NET
Use Qt.
If you're starting a new project and you want to stick with C++, then I highly recommend Qt. Not only is it an excellent framework, but it's cross-platform so your app could be built on Linux and the Mac.
http://www.qtsoftware.com/products/
A Visual C++ plugin is available and you can design your main window visually using a tool called Qt Designer.
I'm not sure if I understand what you want your app to look like. If you want your application to be a dialog, then make it a dialog app.
Just create a new MFC Application, and set it to "Dialog based". Now your application will start at that dialog.
If you want to use a native win32 app, just create the dialog in your InitInstance, using CreateDialog (instead of CreateWindow).
In both cases, you use the resource editor to create the dialog.