Creating a GUI with MFC
Solution 1
MFC is simple when you keep withing bounds of what it's supposed to do (basic Doc/View, dialogs, no fancy candy UI...); as soon as you need to extend the basic behaviour, it get harder and harder to do.
Solution 2
I'd have to agree that for MFC work, the resource editor which is part of Visual studio is probably the easiest way to get going with MFC. You can just lay your controls out on a dialog and stretch them to appropriate proportions. For the record, MFC is a framework it's just that it comes bundled as part of Windows.
If you want your controls to resize, you'll need to add some code to handle the resize (ON_SIZE I think it is) messages delivered as the dialog is resized. This isn't too bad as long as you don't want to resize / reposition too many things at once.
Personally, I'd recommend avoiding MFC in favour of WxWidgets. There's some great GUI layout programs like wxDesigner which can make creating resizeable dialogs and property pages fairly effortless.
Solution 3
MFC is a pain, IMO. Unless you need to program with c++, I recommend using C# with WPF or WinForms. It's much easier. And if you need to use c++ there are better GUI solutions, like Qt.
Solution 4
I have used MFC for over 10 years. Its not bad and I would recommend it over other non Microsoft frameworks as long as you are not interested in running your application on other platforms. If you want your application to look like a dialog, then use CFormView like Aardvark suggested and lay it out with the dialog editor. In a lot of my MFC programs the views are CListViews or an explorer like application with a tree on the left and a ListView on the right. Another one we use a lot is a generic CView with a tab control and a property pages. In those, you don't have the layout issues. You simply create the controls and position them at some predefined distance from the edges. The Prosise is very good. That's what got me going on MFC. Check out CodeProject.com for some classes that extend MFC, for example, resizing dialogs and property sheets. Brian
Solution 5
Which version of Visual C++ are you using ? All the versions I have used come with a pretty good graphical tool for placing and editing GUI components. I usually add the basic components required write some code for them to see how they look and then move things around trying different layouts before I settle on one and add the other component parts.
Even though I have been writing MFC apps on and off for years and quite like it I have to agree with the poster who asked why you are bothering learning. These days you would probably be better using your time learning either C# or Java.
Admin
Updated on July 09, 2022Comments
-
Admin almost 2 years
I recently started learning MFC (Prosise book), and I feel like it's difficult. But the most difficult part seems to be about creating user interfaces. It seems like you have to know the positions your controls should be positioned at (not the case with dialog based apps).
How do you get around that? Do you first draw the application in Photoshop, then measure the distances there?
And also, are there any GUI designers for it? (to ease the pain). I like it a lot, especially because of the speed and the fact it doesn't require a big framework.
Anyone who does MFC programming regularly is welcome to give me advice on how to get good at programming MFC.
-
Valentin Galea almost 15 yearsMFC is bloated and Java isn't:))?
-
Tim over 14 yearsI can't stand the look and feel of java GUIs. They are horrible. I don't know anyone who prefers java ui over native UIs
-
Bo Persson over 11 yearsCan you please tell us something about the advantages?
-
Lothar over 8 yearsEven 6 years later, i say that MFC is still better then QT if you want a windows app, or if you have the manpower to design a native GUI for each platform.
-
Bahramdun Adil about 7 years@Tim Java support many look and feel, e.g window native and so on. So Java is the best also, and is realy very easy to do work with, and there very powerful layouts which handles the resize problem and so on...