regarding mfc dialog bar - c++

I am new to MFC and VC++ programming. I have two questions:
How do I make a resizable dialog bar?
How do I give background color for a dockable dialog bar?
Thanks!

So i assume we are working in visual studios 2008 or similar and i assume you have an MFC SDI or MDI application that you are working on.
Open the resource viewer (View->resource view).
Expand the project that you would like to place the dialog in.
Expand to the dialog folder.
Right click this folder and click add resource.
Expand and add a new dialog bar.
Give it any properties you like using the properties window.
To (display/ give context) your dialog bar, instantiate and get the
handle of the dialog. Like
GetDlgItem(ID)-> ShowWindow(SW_SHOW);//show
Where ID is the id of the dialog. You can obtain this by going into the resource viewer, right click on the dialog, properties, and the ID is given in there.

Related

How do I edit my Windows Desktop Application main dialog in VIsual Studio Commun2019?

I have to create a Win32 app for a college class.
I created the "Windows Desktop Application" in the create project section of the Visual Studio Community 2019 and it comes already with a standard dialog that can be tested on the go. Problem is: I cannot edit the main dialog. I can create another dialog and edit it but the main one is not accessible in the resource editor. What can I do? I can't find anything on google. Please help.
The main window of the default application created by the "Windows Desktop Application" project template in Visual Studio is not created with a dialog resource. It is created by registering a window class associated with a window procedure, as is standard when creating a desktop application.
You "edit" that window by changing the source code not with a visual editor.
>>I cannot edit the main dialog. I can create another dialog and edit it but the main one is not accessible in the resource editor.
Yes you can create it, but it has no class and can't be an object.You can try to create a Win32 desktop application, and then create a dialog. When you right-click the dialog box, you will find that you cannot add class.
If you want to use this dialog, you can only use this function DialogBoxW(hInstance, lpTemplate, hWndParent, lpDialogFunc) to create and show the dialog in your program. The third parameter is the Handle of parent window and it can be NULL. The forth parameter is the callback function.
So we test to call DialogBoxW in WinMain. You can check the picture below. We abandoned the traditional Win32 framework and made the custom window our main window. It work.
However, it should be noted that windows created in this form are modal, which is not applicable in many scenarios. What you say and what you want to do may be better done with MFC. Win32 does not encapsulate many interfaces like MFC for you to call.
I use Visual Studio 2013 Enterprise, but the procedures will be the same:
1 - On the Solution Explorer, click on the .RC file
2 - In the new window (Resource View), click in Dialog
3 - Double-click the dialog you want to edit...
That´s it...

How to insert more dialogs in MFC Dialog application?

I am trying to build an MFC application Dialog based application. It runs ok. But I need to insert another Dialog. So how can I for example, pressing on a button from the first dialog to open the new added dialog?.
I am using Microsoft Visual Studio 2015.
I right clicked on the resources folder and insert a dialog.
It is inserted, but how to create it?.
Thank you.
The easiest way is: I consider you are creating a Dialog based application so you get a main Dialog box and an About Dialog box when Selecting menu->About.
To add Another Dialog to your application:
1- Right click on the solution explorer on the resources files and select Add->Resource->Dialog->New
You get a new Dialog right front of you. Right click on this Dialog and select Add Class. give it for example a name like "MyDlg2" and click ok.
You'll see two files added: MyDlg2.h and MyDlg2.cpp.
Now How to Popup this second dialog (MyDlg2)? Let's create a button on the main Dialog:
Drag a button onto Main Dialog.
Give it a caption "Gong to Dialog2..."
Double-click this button to add a handler for it.
In this handler enter:
MyDlg2 dlg;
dlg.DoModal();
Scroll to the top of this file and add:
#include "MyDlg2.h"
This is important so that main Dialog knows How to create dialog 2.
Build and run.
You need to derive a class from CDialog.
For more information check this MSDN example.

How can I put a menu inside a CDockablePane?

I would like to put a menu inside a CDockablePane so that the pane can have a standard menu as well as a toolbar. The menu itself does not have to be dockable (neither does the toolbar).
As my first attempt, I started with a standard SDI from the VS project wizard, with a dockable Properties pane from which I cut out all the content except the toolbar (I'll be adding a form view eventually). I then tried putting a standard CMFCMenuBar into the pane in much this same way as is done for the main menu in the main frame, but with the dockable pane as the parent. This eventually displays OK in the pane, but only after ignoring various ASSERTS along the way (and on exit), presumably because it is expecting a CFrameWndEx rather than CDockablePane as parent. I suspect it's getting in a tangle with the main frame dock manager.
I would greatly appreciate any advice (or better still sample code) on how to do this properly. Clearly the CMFCMenuBar route is a kludge.

Not able to see the add variable wizard in mfc

I'm using visual studio 2010 and i'M creating aN MFC dialog based application. Everything was working fine until recently when the add variable wizard stopped showing up when we right click on a control in main dialog and choose add variable.
I have 3 dialogs in the project. The add variable wizard shows up for the other dialogs. Only for the main dialog the wizard is not showing up, ie. nothing
is happening when we right click and choose add variable on say picture control embedded in main dialog.
I'm using 64 bit Windows 7.
The problem was ID mismatch(ID of main dialog) in the properties of dialog and the header of the corresponding class of the dialog. It is fixed and is working correctly now.

Qt how to create a settings/configuration window

I was trying to find an example of creating a settings/configuration windows. The settings window is launched by clicking "Options" action in the menu item. I wanted to figure out how to open up a 2nd window from the main window. As well how the new window return the settings information back to main window. Tried to play around with the QDialog or some inherited dialog classes, but those are for limited uses, not for general setting window. Is there any example/documentation about this?
Have you seen this property browser. Similar to property editor in Qt Designer. qtpropertybrowser Image