views:

293

answers:

2

I'm trying to learn how to write Windows GUI* programs in C++, using Visual Studio 2008, but I haven't found any more comprehensive tutorial for beginners.

The more comprehensive tutorials I have found are either only about how to make buttons, menus, etc. OR only about how to write basic C++ console programs.

What I haven't found is a more comprehensive tutorial for beginners on how to combine buttons, menus, etc. with C++ code.

In other words, I'm looking for answers to the question: How do I link menus, buttons etc. to C++ code?

If you know where I can find answers to that question, post them here, please!

Note: "Graphical User Interface (GUI): Includes such things as icons, panels, and interactive windows, to enable users to perform such actions as opening files and creating applications with the click of the mouse" (intoweb.co.za/et-linux-tips.html).


I'm currently reading a C# tutorial at techotopia.com, that seems to include not only C# basics but also useful information on how to use C# to get buttons, menus. etc. to actually do something. I only started reading the tutorial, though, so how useful it actually is I don't know yet.


I've now finished reading the C# tutorial at techotopia.com and learned some basic facts about how to actually make controls on a windows form do something. Had I known what I now know about C# earlier, I most likely would have chosen to learn that language before I started learning C++.

It's beyond me why each and every C++ GUI programs tutorial for beginners aren't written in the same style as the tutorials at techotopia.com. I see no reason why C++ GUI programs tutorials for beginners can't be both crammed with basic facts AND explain even the simplest things to people like me, that need such explanations to understand a new subject. Well, there probably are such tuturials, only I haven't found them.


Now is the time, I think, to make a short list of what steps I have taken to get where I am today when it comes to computer skills in general and ability to write computer programs in particular. I'm posting the list here for the benefit of people who wants to become good at writing computer programs but don't know how to reach that goal or have mislead themselves, as I have time and time again. It's not a final list in any way. It's just a short account of what have worked for me.

Step 1. Use lots of computer programs (word processors, image editors and what else you're interested in) to see what can be done with a computer.

Step 2. Write web pages with HTML and CSS. HTML, Hypertext Markupup Language, are used to tell browsers things like the beginning and end of paragraphs, the structure of tables and where to include images. CSS, Cascading Style Sheets, are used to add things like text-size and background-color to web pages.

Step 3. Improve your web pages with PHP. PHP, Hypertext Preprocessor, reminds of C# and C++ and is a server-side scripting language. Server-side means that something is done to a web page before it is sent to a visitor's browser, like adding code that makes it possible to send a message. PHP is easier for a beginner than C# and C++. Also, if you have written some HTML pages, you can gradually add PHP to these pages. In other words, you can learn how to use PHP in a familiar context.

Step 4. Learn C#. Reminds of PHP and C++. More difficult for a beginner than PHP but easier than C++. This is where I am right now. These links may be of at least some use:

Step 5. Learn C++. Reminds of PHP and C#. More difficult for a beginner than PHP and C#. Allows the programmer to control more than C#. Some people say it's faster than C#, while other people don't. This is where I hopefully will be within a year or so.

Since there are as many roads as there are budding programmers, these steps may not be right for you. Hopefully, though, the list above is of at least some assistence to you when you decide what steps to take to reach your goal.

If you know more about programming than I do and disagree with the list above, feel free to provide your own list. If you do, I think you should also explain why you think your list is better.

+3  A: 

Charles Petzold wrote a book on that.

I haven't read it, but his Win32 UI book is widely known as hilarious, so it is expected to be good for beginners.

Pavel Radzivilovsky
AFAIK, Petzold wrote about native Windows APIs with C and C++, and a separate book about Windows Forms with C#, but no book that combines the two. This is what the OP observed.
Ben Voigt
I don't want to buy a book. I've bought to many computer books already, that was either too easy or too difficult. I'm looking for an on-line tutorial.
matsolof
You can get a used Petzold book on Amazon for typically <$20. That's a steal considering the wealth of information. I was like you at one point - I was constantly searching for tutorials on building Windows GUIs in native C. I finally got a hold of "Programming Windows" and it was what I was looking for the whole time.
brady
Well, as I said, I've already bought several computer books, including several books on C++, but I didn't find any of them that helpful. It's probably because I'm a slow learner and need information piecemeal, like in tutorials, when I study a new subject rather than a lot at once, like from a book. I haven't bought any book by Petzold, though, so I will check it out because you recommend it. What's the title? by the way.
matsolof
"Programming Windows" by Charles Petzold.
quixoto
Thank's for the title! I see now that I've already gotten the title from brady. I didn't see that earlier. I've also marked a couple of the comments above as "great". I didn't know you could do that until yesterday.
matsolof
+2  A: 

As you can probably already tell from other answers and comments, the term "Windows Forms" is the name for a specific .NET technology.

You seem to want to ask a question more along line of how to learn to write Windows programs that have a GUI (menus, buttons, windows, etc).

There is no single way to write a Windows program. C++ itself doesn't know anything about Windows. Instead you will end up using some API or framework. So what you need to do is choose which particular one you want to use and then learn that.

  • At the lowest level there is the raw Windows API. However it is a very C-like interface and few people would recommend starting there.
  • Microsoft's C++ based framework for building Windows programs is MFC (Microsoft Foundation Classes). It was created long before .NET and C++/CLI and such. Being so old, there are aspects of it that haven't been able to change to keep with the times and so some people don't like it. But it's still supported and used. In fact, if you have a full version (not an express version) of Visual Studio then you already have MFC available.
  • There are various other C++ frameworks that have come along more recently. Qt and WxWidgets are a couple of the bigger names. Many of these not only give you a way to create Windows programs, but also try to abstract away all the OS-specific details so that your code can be compiled to work on other OS's (like Linux or Mac) too. In my opinion, these are often more pleasant to work with than MFC once you learn how.
  • Even though its not what you're asking for, many people would actually recommend using C# and .NET for making GUI programs in Windows. There are some nice aspects of that language and framework that make GUI programming easier.

So you probably need to do a little investigation to determine what technology you actually want to learn and use. Then you can go searching for appropriate tutorials.

TheUndeadFish
Thanks for the comments! I didn't know "Windows Forms" was the name for a specific .NET technology. Your educated guess that I want to learn how to write Windows programs that have a GUI is correct. I know C++ doesn't know anything about Windows and that I need to use some API or framework. I even know about the rest of the technologies you mention (the Windows API, MFC, .NET, C++/CLI, Qt, WxWidgets, C#).
matsolof
I have read several tutorials on C++ and been experienting a lot with making forms with Visual Studio 2008. The problem is I haven't found any more comprehensive tutorial for beginners on how to combine the C++ code with the forms. That's what I'm looking for.
matsolof
I recalled that the reason I want to use C++ is that it's supposed to be faster than C#. I also recalled that I have checked out several benchmarks of C++, C# and other computer languages and that according to these benchmarks C++ is about the fastest computer language there is (beside Assembly, but I don't indend to learn that).
matsolof
However, I don't trust benchmarks that much. I have been using PHP several years and concluded that benchmarks (mine and others) more often that not contradict each other. What are your thoughts on the subject of the speed of C++ versus the speed of C# versus the speed of other computer langugages?
matsolof
@matsolof Well, the way to connect your C++ code with the actual GUI is different in each framework. Often it involves deriving from some kind of "Window" class provided by the framework, but the details are different in each one. Any tutorial will be specific to that framework and not terribly useful otherwise. So that's why I say you first need to decide on which technology you're going to use.
TheUndeadFish
On the subject of performance: Yes, C++ can often get better performance than C#. But C# is still quite sufficient for many tasks. In a performance-intensive application (such as a high-end 3D game or large simulation), C++ might be significantly better. On the other hand, many GUI programs spend most of their time simply waiting for input from the user. The performance of the language isn't much of an issue because the typical processing can be accomplished in a tiny fraction of a second in either language. Any difference is too small for the user to see.
TheUndeadFish
Thanks for the comment! I probably should have realised long ago that the connection of C++ code with the actual GUI differs in every framework, but actually I didn't. The reason I worry about C# performance is because I sometimes do things like replacing something in 100.000 files or more and will most likely write programs that do that kind of things. In Dreamweaver, for example, that I usually use, such a task takes if not forever so at least maybe ten or twenty minutes.
matsolof
@matsolof If that's your specific concern, it's useful to understand the file-activity intensive programs will be "bound" in performance by the disk activity, not by the the speed of your running program. And I'll double down on others' comments-- C++ is something you may wish to learn at some point (and I'd recommend it), but don't learn it because "it's faster"-- in general, it's not faster in any meaningful way. You'll probably end up getting into it because you want to try some domain specific code: games or graphics or audio processing or something, where you get less language choice.
quixoto
Thanks, quixoto! Good to know. What about how much a programmer can control? As far as I understand, you can control more if you use C++ than if you use C#. Am I correct or have I got that wrong too? PS: I just realised it's possible to mark comments as great. I've marked a couple of the comments above.
matsolof