Fog Creek Software
Discussion Board




C on windows?

Hey, guys.  I been programming in C on linux for awhile now.  Now I want to get into window programming, GUI/socket, etc.  As I reading more and more into window programming on the web, it seems to me that most of Window programming is C++ (MFC, etc).  Should I just pick up C++, since I know C pretty well?  Or I can use C for window programming?

New window pr0pr0mer
Friday, May 21, 2004

Start with the raw C Win32 API (Petzold's book is great for this). Then you'll have a much easier time picking up MFC.

MFC doesn't use that many super-advanced C++ features, so as long as you understand basic stuff classes, inhertance, and virtual functions, you should be OK.

Dan Maas
Friday, May 21, 2004

If you install the cygwin for Windows package you'll have the option of installing the GNU C++ compiler, the same one that's probably runing on your Linux box.

C++ is all about OO - it's not a small step from C to C++, but you can use the C++ "as a better C" in the meantime.

5v3n
Friday, May 21, 2004

Sorry, I wasn't clear on my post.  I know C just fine.  I'm more interested in programming windows API.  So cygwin doesn't really do it for me, I figure I just use VC++ and pick up C API for windows.

New window pr0pr0mer
Friday, May 21, 2004

Start with C and Windows API. During the same time look into C++ too. Then later learn MFC and try to start without using wizards. Knowledge of Windows API and MFC (without wizards) will really come handy when you'll be stuck on something.

Green Pajamas
Friday, May 21, 2004

I mean when you'll generate a skeleton MFC program with a Visual C++ wizard and then "stuck" on something. :)

Green Pajamas
Friday, May 21, 2004

You ought to pick up C++ or some other language that supports basic object-oriented concepts (Objective C would probably be just as easy for you to move to).  You'll need to know it eventually.


Friday, May 21, 2004

So Petzold's book on Programming Window is good for learning C API?

New window pr0pr0mer
Friday, May 21, 2004

Petzold and Microsoft SDK samples are probably your best bet for learning the Windows C API.  The basic concepts are the same as they were in the days of 16 bit Windows. 

Direct use of the API for everything isn't too popular these days but the knowledge can be useful.  Hope you like the switch statement.

Doug
Friday, May 21, 2004

May I recommend that you put all the examples from
Petzold into one project. That's what I started to do
from 5th chapter and that way I was able to find things that
I new I did before but forgot how.

At the same time you'll start creating your own utilities
and learn how to juggle many windows and dialogs at the
same time.

Web sites:
http://www.codeguru.com/sitemap.php
http://www.codetools.com/win32/

These two are not so popular but are lifesavers anyway:
http://www.flounder.com/
http://bobmoore.mvps.org/

Usenet:
comp.os.ms-windows.programmer.win32
Just google for anything there and you'll find it in no
time.

Download Wine and try to read stuff in there.

I was in same situation very recently. You can always
try to learn new platform AND new language AND new
dev tools at the same time. In my case it turned out that
I can only pick only one and don't give up after several
months.

Best of luck!

VPC
Friday, May 21, 2004

I'd have to recommend using something other than C for programming GUI on Windows. Starting with C#, though there are other good choices.

If you have existing C code that you want to leverage, you could just do the GUI in C#.

MilesArcher
Friday, May 21, 2004

Is anyone using MFC for new development anymore?  Since I was never a C/C++ guy, I've never known much about MFC, but my understanding is that MS is pushing people onto the .Net framework now, which can be used via C++ but isn't anything like MFC.  Or am I off base here?

In any case, you will have to spend some energy to make the transition from procedural to OOP (be it in C++ or a new language like VB.Net or C# w/ .Net).  It's something a lot of people stumble on, so don't get discouraged if it seems strange at first.

Joe
Friday, May 21, 2004

What do you want to do?  If you just want to do low level drawing to a top level window than C is fine.  To me wrapping GDI, etc., isn't really that much of a benefit.  Message routing is the biggest gain you get with frameworks IMHO.

christopher baus (www.baus.net)
Friday, May 21, 2004

I have to disagree with most and say don't get into Petzold and the raw Win32 API. There's way too much to learn that is obsolete now that C# is around, and nobody is programming raw Win32 GUI's anymore and I doubt starting serious new projects with MFC either. C# is just so much easier, and it can do everything the old Win32 API did.

Rick
Friday, May 21, 2004

"There's way too much to learn that is obsolete now that C# is around, and nobody is programming raw Win32 GUI's anymore and I doubt starting serious new projects with MFC either."

Ugh...nobody in internal business development groups, developing internal applications for a small audient, are, but I assure you that a whole heap load of commercial software companies are.

However if the OP is a Linux programmer, I'd recommend skipping Windows specific code wherever possible, and instead try out something like wxWindows -- write cross-platform code and efficiently target multiple platforms.

Dennis Forbes
Friday, May 21, 2004

Ugh... if you write cross-platform code then you have to maintain multiple platforms, debug on multiple platforms and build on multiple platforms (otherwise why do it?). Except all your customers are just on one platform, Windows.

Seriously, who would start a new commercial product today in MFC? There may be lots of legacy code in MFC that's still being extended, but if anybody is starting a new project on a blank .cpp file using MFC, they're complete idiots.

Rick
Friday, May 21, 2004

Ok, thanks for the response.  The problem is that I havn't program for any window apps, also unix.  So my knowledge of windows system is ZERO.  I don't just want to write GUI, but also network, etc.
My question is: where do I start?  My strong point is at C/Python/Tcl.  How do I start programming for Windows?

New window pr0pr0mer
Saturday, May 22, 2004

You're in for a hell of a learning curve.

The shift from procedural programming to message/event programming is pretty drastic. It's going to take a while before it really sinks in.

I wouldn't normally recommend learning Windows in C, but since you already know C, I'd concentrate on learning one thing at a time, and go ahead and get the Petzold Win32 book and do that. It's going to be ugly and hacked looking, but there's always time later to transition away from that and into an object framework later.

Brad Wilson (dotnetguy.techieswithcats.com)
Saturday, May 22, 2004

Hmmm. So you want to learn GUI programming, Network programming, OO programming, etc.

Traditional approach:
1. C and Windows API (skip this and regret)
2. C++ and MFC
4. WinSock / Windows Internet (aka WinInet) / CSocket

.NET approach:
1. C#
2. System.Windows.Forms namespace (or use VS.NET).
3. System.Net, System.Net.Sockets  namespace.

In the .NET approach you should be up and running in few days to few weeks. But in the traditional approach, I really can't say. Previously, I said that you should go for C and Windows API, but since now you seem more interested in GUI and Network programming - just go for C#.

Green Pajamas
Saturday, May 22, 2004

Wow, I tho knowing C would help me to learn Window.  It seems everyone here thinks C & window API is abit old or not very useful?  Is it true that C# and the whole .Net is becoming like Java, where high-level programming.  One thing I didn't like about Java is that it's so high level, while using JNI can combine C/C++ code, I find it difficult doing that all the time.

New window pr0pr0mer
Saturday, May 22, 2004

If you have the time, learning Windows from the ground up with the C API will definitely give you a much more thorough understanding of how things work and prepare you for things that people jumping right into .NET might find baffling.

On the other hand, Longhorn is supposed to rebase the Windows architecture on .NET and change quite a few things... so who knows how long this knowledge will be valuable. Up to five years at least, beyond that it's questionable.

Chris Nahr
Saturday, May 22, 2004

New window pr0pr0mer says "My strong point is at C/Python/Tcl."

If you know Tcl (and Python), why not start GUI programming with Tk ?  It won't give you the low-level insight into the guts of Windows that you'd get from learning MFC, but you'll produce useable GUI applications a lot faster.  Also the Tcl networking facilities are easy to get started with, and event-based programming in general is relatively painless in the Tcl framework.

Colin Macleod
Saturday, May 22, 2004

I have no problem with using Tcl with Tk.  Like I said before, the real thing I want to learn is Window-based programming as in using window API, not just GUI applications, I don't know where to start!!!!  .Net, VB, VC++, C.

New window pr0pr0mer
Saturday, May 22, 2004

New window pr0pr0mer,

If you only want to develop Network-aware applications with GUIs then go for .NET. All you'll have to do is to learn C#. A good book on C# should introduce you to creating Windows-based applications using nothing but C# code. While working on an actual project you can use Visual Studio .NET, it can help you "generate" a lot of code - especially for GUIs. You can design GUIs visually with VS.NET. Some books on C# also provide introductory material on simple network programming using TcpClient (for clients), TcpListener (for servers), etc.

But, if you follow the other path. You'll need to learn about the Windows API, C++, MFC, Windows Sockets and Multithreading (and what knows COM) at the least. Let me be straight - it's a lot, it's hard and it's scary :).

If you want to write a shrinkwrap application then instead of going for the longer path, just stick with .NET and develop your application. The year or two you'll spend on learning pre-.NET development can be well spent in improving and marketing your .NET-based application while we make a transition to Longhorn.

Green Pajamas
Saturday, May 22, 2004

*  Recent Topics

*  Fog Creek Home