Creating a GUI with MFC

2019-06-19 02:19发布

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.

11条回答
forever°为你锁心
2楼-- · 2019-06-19 02:48

You can get excellent results using MFC without having to add any other framework. Here is an example of a utility I have created.

查看更多
不美不萌又怎样
3楼-- · 2019-06-19 02:53

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

查看更多
【Aperson】
4楼-- · 2019-06-19 02:53

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.

查看更多
Anthone
5楼-- · 2019-06-19 02:59

MFC applications can get pretty bloated (e.g. large application executable size, memory footprint, and/or require runtime DLLs to be used along with your application). If you are focused on C++, I'd recommend looking at WTL instead (used to be a Microsoft library but it's now on SourceForge). It's a very lightweight alternative (using templates) to MFC with similar syntax.

Lately I've abandoned C++ for Java for most of my applications including GUIs, and I don't plan on going back.

查看更多
成全新的幸福
6楼-- · 2019-06-19 03:00

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.

查看更多
Evening l夕情丶
7楼-- · 2019-06-19 03:00

A lot of the time you use the dialog resource editor and data-binding to create a UI in MFC (you can have a dialog based view). If you're not creating a dialog, then usually you have some algorithm in mind for layout of the controls, and implement that.

查看更多
登录 后发表回答