View Full Version : Need some advice about moving into windows programming using C/C++
ftrguy
03-28-2003, 10:41 PM
I've been playing around with C and C++ for quite some time now, all on console applications, and now i've decided it's time to start creating applications using windows, menus, toolbars etc etc. But i'm a little confused on how to go about it.
At first I tried Win32 API programming, but I found it to be too low level to be used to create applicatons with. Altho i did learn about messaging between Windows and applications, which has really helped me now that i've moved onto MFC. I've just started MFC programming, and i like it's use of OO, and it seems to be a little better then Win32 API programming.
(i've only started to dable with Win32 APIs, MFC etc so correct me if i'm wrong on any of the above points.)
Am i on the right path using MFC? should i go back to Win32 APIs? or something else?
The reason i'm asking this, is that soon i would like to move into a commercial programming position, and i was wondering how companies go about creating windows applications using C/C++, so i can develop those skills.
Any comments will be appreciated. Thx.
Btw, i'm using MS Visual C++ 6.0
Paul Victorey
03-29-2003, 12:30 PM
MFC is definately the fastest way to get a C++ windows app. I do a lot of stuff in Windows, and I've used pure WinAPI, use Borland's OWL, and used MFC, and I like MFC the best. Visual Studio is pretty good, although it takes some time to figure out where they hide some of their features.
I've never done programming commercially, but I know for a fact that at at least one company, they use MFC when they're doing builds for Windows machines. I'd suppose most companies would -- it's the fastest way to do a lot of things, because a lot of the nitty gritty details, like message pumps, are hidden.
On the other hand, it's very good to know WinAPI because MFC simplifies things, and if it simplifies out the feature you wanted to use, you should be able to fallback on WinAPI if needed.
I can usually write full programs without needing much WinAPI, if any at all. MFC is definately a handy tool.
I think the biggest things to learn are good OOP techniques if you want a job in programming. Learning something like COM might be beneficial, it essentially describes a well-thought out and object-oriented interface. Create a few DLLs with code you want to use, create a few versions, and do it all using the COM model, and you'll know a lot.
Oh, and learn how to access DLLs, both that you create and that others create. It will definately help.
ftrguy
03-29-2003, 07:56 PM
Thx for the feedback Paul, i guess i'll continue working with MFC. Right now i've only started with the basics, and most of the apps i've written still require message handling, but i've read that the apps wizard really helps in cutting down code.
As you've mentioned, MFC does try to simplify things, but it's good to know that you can still directly call the WinAPIs. so there's still that low-level control that i like in c/c++, compared to other high level languages.
When i get my head around MFC, i'll look into COM and DLLs. I've played around with DLLs before, and written a couple, but nothing major.
Back to the books i guess. Thx again.
Paul Victorey
03-30-2003, 12:41 PM
You still need to do message handling, but as long as you use CWnd classes, message handling is nothing more than making a finction to respond to the message, and making an entry in a macro table. E.g.:
BEGIN_MESSAGE_MAP(CDrawDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_BN_CLICKED(ID_LOAD, OnBnClickedLoad)
ON_WM_HSCROLL()
ON_BN_CLICKED(ID_FILTER, OnBnClickedFilter)
END_MESSAGE_MAP()
And then simply create the functions (OnBnClickedLoad(), etc). No need to have a manual message pump, just throw a macro in the table. And it will even auto-generate most handlers (though not all possible message handlers can be auto-generated -- in that example, I had to manually type in the scrollbar handler line).
ftrguy
03-31-2003, 07:22 PM
yep, thats what i've been using. it's a little neater than the winAPI equivalent, but of course, the logic behind it is still the same.
Paul Victorey
04-01-2003, 01:27 PM
Yeah, that's basically all MFC does -- makes it a little faster, little cleaner, etc.
The logic is exactly the same, so it really pays to know WinAPI too.
doctorgonzo
04-01-2003, 03:22 PM
I started doing Windows programming using only the API, and although it was harder, I think it helped to know that stuff. Later, I got Visual Studio and started using MFC, and it certainly speeds things along. I am glad, though, that I learned the API, so I know what all of those shortcuts are doing.
vBulletin® v3.7.0, Copyright ©2000-2008, Jelsoft Enterprises Ltd.