Anyone know good books for c++ forms?

Started by
9 comments, last by LorinAtzberger 14 years, 3 months ago
For Visual C++ 2008....are there any books that go over the full functionality of the Visual c++ forms? I'd really like to use these forms rather than writing out my own GUI. ;o
Advertisement
If you are talking just using the Win32 API to make Windows applications then Programming Windows by Charles Petzold

"I can't believe I'm defending logic to a turing machine." - Kent Woolworth [Other Space]

When you say "forms" I assume you are referring to forms as implemented in the .NET framework?

If so, I don't think you will find many books that use managed C++.

Probably best to look into using the C# language and books\tutorials and examples that use that language.
For the love of god, please tell me that you've just omitted your error checking code for brevity, and you don't really assume that all those functions succeed.
If you are wanting to use the Dialog Editor in generic C++, then you will need to just understand generic Win32 API coding. In a sense, all it saves you is from having to call CreateWindow/Ex for each control. Every other aspect you must still code yourself, so if you simply find resources on Win32 GUI programming, most of it is applicable, just not the creation and layout of the control.

If you were using MFC along with C++, then the Dialog Editor offers a lot more features for code generation and event handling, but you would be using MFC. If you go that route, then it helps to understand the basic Win32 API, but you would just be looking for resources on MFC programming, which there are many since it has been around for so long.

Overall though, GUI programming using the base Dialog Editor in C++ is very tedious and frustrating compared to using another existing GUI library or moving the GUI portion of your project to a higher level language like C#. You won't quiet find explicit instructions on how to do everything you might want, so its a lot of trial and error and mining the web for examples of things you want to do.

I've done quiet a bit of GUI programming in C++ over the years, and let me tell you, if you can find a way to move the GUI to something else like C# and interface your C++ backend to it using some form of IPC, you will save a lot of time, frustrations, and easily end up with something that works and provides a functionality that is 10x better than what you can do if you stick to coding it all by hand using the Dialog Editor.

I suggest taking a look at that approach, or getting into a MFC project, or use an external GUI library like Qt or wxWidgets. Going the route of using the Visual Studio dialog editor otherwise just is so inefficient nowadays.

I mean, I'm not trying to discourage you from looking into it, but you can put a lot of time and effort into your GUI and in the end, it looks like crap and someone can spend 1/10 the time and effort you did using C#'s WinForms and have something that blows your GUI clean out of the water. When the final product doesn't accurately portray your hard work, then that's enough of a reason for me to try new things where it would.
Quote:Original post by Drew_Benton
I mean, I'm not trying to discourage you from looking into it, but you can put a lot of time and effort into your GUI and in the end, it looks like crap and someone can spend 1/10 the time and effort you did using C#'s WinForms and have something that blows your GUI clean out of the water. When the final product doesn't accurately portray your hard work, then that's enough of a reason for me to try new things where it would.


If there's easier ways to do the GUI in C#, then I'll go that route for sure. I've actually heard about people doing the gui in c# but wouldn't I need to spend some money on Visual Studio or something? O_o

Or..how would I put the c# and c++ code together. I'm only using VC++ 2008 express edition at the moment...and a total newb to this. O_o
Quote:Original post by OneThreeThreeSeven


If there's easier ways to do the GUI in C#, then I'll go that route for sure. I've actually heard about people doing the gui in c# but wouldn't I need to spend some money on Visual Studio or something? O_o

Or..how would I put the c# and c++ code together. I'm only using VC++ 2008 express edition at the moment...and a total newb to this. O_o


You can use Visual C# 2008 express edition for free when coding in C#.

If you are talking about linking native c++ with C# code, rather than managed c++, then I can't give you a simple answer.

The best I could do would be to ask you to google on "interop" and "pinvoke".

HTH

For the love of god, please tell me that you've just omitted your error checking code for brevity, and you don't really assume that all those functions succeed.
Quote:Original post by OneThreeThreeSeven
If there's easier ways to do the GUI in C#, then I'll go that route for sure. I've actually heard about people doing the gui in c# but wouldn't I need to spend some money on Visual Studio or something? O_o


Microsoft offers Visual C# 2008 Express Edition just like they do for C++, so you would not need to buy Visual Studio Professional.

Quote:Or..how would I put the c# and c++ code together. I'm only using VC++ 2008 express edition at the moment...and a total newb to this. O_o


This will be your main hurdle to overcome with the setup, but even if you are new to it, its ok because like with anything else in programming, as long as you are willing to put the time and effort into it, then you can do it. However, please explain a bit what you are wanting to do with your GUI or some information about your project. The concepts are pretty general, but depending on what you have needs for, it can either be easier or harder than it has to be.
What's the difference between native and managed c++? O_o

All I want to do for now is make a GUI with some buttons and a progress bar.

I've been looking over wxwidgets...I guess I'll look more into that.
Looks like Wxwidgets is what I'm gonna be working with. It looks pretty nice...and I don't have to relearn anything. ;o
Quote:Original post by OneThreeThreeSeven
What's the difference between native and managed c++? O_o


Native code is 'native' to the platform it runs on, if you write in unmanaged C++, the compiler will spit out native code.

"Managed" C++ (or C#, etc.) requires a "Managed" environment i.e. the CLR Virtual Machine. .NET code runs on a VM rather than directly on the platform, although this is mostly transparent to the end-user (unlike Sun's JRE...)

Managed code implies all sorts of cool stuff like Garbage Collection. Native code allows for some cool stuff too, like writing assembly language directly into your code.

I almost never write unmanaged code anymore. I have used C++ to create the interfaces to some assembly language to be accessed by a C# application to perform fast image processing, but that was not until after I had optimized an existing C# loop until it was as fast as it could be, and then rewriting some key components of it in assembly. So yes, what you are thinking of doing is entirely possible.

One way to do it is to create a managed C++ project, with two classes, an unmanaged and a managed class. Call the unmanaged class something like NativeCode, and reference your native code from the managed class in the project. Then, you can just load the assembly in your C#/GUI/Managed C++/Whatever project (at runtime, or add as a reference) and call it directly.

Quote:

All I want to do for now is make a GUI with some buttons and a progress bar.

I've been looking over wxwidgets...I guess I'll look more into that.


It's pretty straightforward to get this working in WPF/WinForms/MFC/Win32 (technologies listed from newest to oldest)

WPF -> New, shiny, you'd be learning some fancy tech; not much documentation/information/tutorials on the net yet.
WinForms -> Good standard GUI development, tons of documentation, tons of support, tons of books.
MFC -> I hate MFC, but it's not really that bad. They did a reasonably nice job of wrapping Win32 into an object oriented framework
Win32 -> What it's all based on. When you're first learning it, it can all look pretty stunning in terms of complexity and function calls, but it's not really, once you get the hang of it. However, I wouldn't really reccomend it for serious GUI development as it's old tech.



This topic is closed to new replies.

Advertisement