![]() |
Creating Windows GUIs with C++
This is only slightly related to robo, but...
I've been making Windows applications for about a year since I took a programming class in school last year. The main thing I've done is a server launcher for Command & Conquer Renegade (an old FPS) and its assorted mods. More to the point, I create installers and distribute my programs over the web. I've been using VB.NET. While I love the language, a lot of people who I distributed the program to have complained about the .NET framework, as it requires a large RAM overhead (my program, while relatively small, takes 20 MB of RAM to run), and is sluggish redrawing the window and such on the screen. They are also frustrated with having to download a relatively large framework in the first place. I'm working on acquiring a copy of VB6 to circumvent these issues, but at the suggestion of another member of our code team, I'm trying to do something similar in C++ To make a long story short, I've been teaching myself C++ (due to its similarity to the C we use to program our robots with) so that I can create better, smaller, and faster-running apps. However, since I highly doubt that my users would want do everything in command prompt, I want to create a GUI. I understand it's possible to create windows using only the Windows API, but that's very complex (for me, at this level, anyways), and I've been looking into other options. A fellow code member on my team suggested I used Glade, which is a GUI builder that uses the GTK+ toolkit. Does anyone else have any experience, either in Glade or just creating windows with C++ in general, and if so, do you have any advice for me? |
Re: Creating Windows GUIs with C++
Where I work at Sony Creative Software, we use C++ directly with the Win32 API. It makes for much faster programs, especially when it comes to user interface elements. It's fine to work with once you're used to it, but there's a steep learning curve - mostly because it's written in such a way that it can be used in C (i.e. no classes, just a whole lot of global functions, structures and macros).
I would suggest you look into MFC (Microsoft Foundation Classes). It's basically a Microsoft-written C++ wrapper for the Win32 API. If you're using Visual C++, there are wizards to get you started with MFC applications. Otherwise, if you're interested in using the API directly, I have to recommend this book; it's considered the "bible" of Windows programming. |
Re: Creating Windows GUIs with C++
http://www.winprog.net/tutorial/
Helped me (of course, a little side help from a couple of advanced programmers) create this program: http://rapidshare.com/files/76407628...aller.rar.html the winprog site is a really good introduction to programming API which leads to learning to use OS components and programs. I'm looking forward to starting to learn MFC, which should be the next step for programming applications and so. If you need any help with API, I'll be glad to help. Nir. |
Re: Creating Windows GUIs with C++
Check out the Qt toolkit from Trolltech: http://trolltech.com/products/qt/homepage
It's open source (GPL'd)...so if you create open source apps with it you can use it for free. The docs are great--they have some tutorials and lots of examples. I've used it to create ~3 GUI apps now, and it's worked great every time. - Taj |
Re: Creating Windows GUIs with C++
Also check out wxWidgets
|
Re: Creating Windows GUIs with C++
Awesome guys. Thanks for the help.
|
Re: Creating Windows GUIs with C++
wxWidgets is pretty cool for multi platform free stuff. There is a pretty nice visual compiler called wxDev-C++. The one bad thing about wxWidgets is that it is bulky and is all 3rd party so some things aren't all the way there, its not the most supported. Programs like VLC media player and audacity use wxWidgets. With wxDev-C++ the exe seems to be kinda big.
I looked a little bit at QT and it just seems kinda weird, and I believe you need a license for it. I didn't look into it too much. I would suggest learning the windows programming, you will probably be much better off. Get Visual Studio and maybe a nice book and play around. Or..... You can learn some C#, from what I hear C# and the .net framework are very easy to use and are good for GUI applications. One plus side to C# is all the memory management is done inside the .net framework so you don't have to worry about memory leaks as in C++. With C# you cant do things with memory though as you can in C/C++ though. So it all comes down to personal preference. C# may be easier but I think it is a bit more restricted compared to C++ and with C++ you will probably be writing and debugging more then C#. I don't know too much about C# but this is just what I have heard ;) |
Re: Creating Windows GUIs with C++
Quote:
|
Re: Creating Windows GUIs with C++
I'm having issues now.
My code: This is just a simple "Hello World" using message boxes. Code:
#include <Windows.h>1. When I create an empty solution and insert this code, everything runs fine on my computer, but when I tried to show it to friends they said they all got an error that my application was not configured properly. 2. When I create an empty Win32 solution and insert the code, it refuses to build, telling me for each argument I pass: Quote:
|
Re: Creating Windows GUIs with C++
Your error message is Unicode-related. For every Windows function that deals with strings, there are actually two functions - one that uses ASCII strings (each character is 1 byte wide) and one that uses wide strings (each character is 2 bytes wide). The Win32 API functions typically have an 'A' or 'W' at the end of the name (like 'MessageBoxW').
The problem here is that your build environment appears to be configured to use Unicode, so all the Windows functions like MessageBox are automatically being aliased to their Unicode equivalents, like MessageBoxW. You're therefore trying to pass a string with ASCII characters (declared something like "stringgoeshere") into a function that takes a wide-character string (declared like L"stringgoeshere"). You could just put an 'L' in front of all your strings to force them to use wide characters, but there's a better solution. Windows has a data type called a 'TCHAR' you can use for strings, which is automatically converted into either ASCII or wide characters when you compile, depending on whether or not the _UNICODE preprocessor flag is set. All you have to do is include tchar.h, enclose your literal strings with the _T() or _TEXT() macros, and use the TCHAR data type whenever declaring string variables. Code:
#include <tchar.h> |
Re: Creating Windows GUIs with C++
Thank you. It now compiles. And it works perfectly on my machine. However it still generates an error whenever I show it to somebody else:
Quote:
Code:
#include <Windows.h> |
Re: Creating Windows GUIs with C++
A Google search turned up this - seems like applications built with VS 2008 need to have certain DLLs distributed with them, even if they're just using simple Win32 API stuff.
|
Re: Creating Windows GUIs with C++
It gets better and better.
|
Re: Creating Windows GUIs with C++
Quote:
Another good choice for a C++ framework is WTL, Windows Template Library. It was originally developed as a side project within Microsoft to be what MFC was not, a object oriented C++ solution. Since it uses templates heavily, it's probably not that easy for a beginner to get up to speed on. It was never officially supported by Microsoft and is now an open source at Source Forge. It's what I'm currently using for what little Windows programming I do these days. |
Re: Creating Windows GUIs with C++
So much for being able to distribute just my executable. :mad:
However, I really appreciate you guys. Awesome help. This really shows how awesome FIRST (and CD) are. |
Re: Creating Windows GUIs with C++
Quote:
|
Re: Creating Windows GUIs with C++
Hang on, were you able to send it to your friends?
|
Re: Creating Windows GUIs with C++
Wow! Now I remember why I gave up on Win32 so long ago. I was in pretty much you exact position 5 years ago. After running into so many "gotchas" (I had a different word for them), I decided to cut my losses. I switched to Python and haven't looked back.
I won't start a holy war thread here, but you may want to carefully consider exactly what you want to do, and then compare your available language options before committing. I would also like to highly recommend "How to Think Like a Computer Scientist" by Allen Downey. You can download it for free at http://www.greenteapress.com/thinkpython/ Allen Downey is a prof at Olin College (my alma mater). Several years ago he wrote a Java version of the book and copy-lefted it. Someone took the book, revised it for Python, and rereleased it. Allen then read this book and learned Python. ... Yes, he learned Python by reading his own book! It has some chapters that deal with a little bit of user interfacing, so it shouldn't be hard at all to get going. Good luck! Eric |
Re: Creating Windows GUIs with C++
Not to be a killjoy but I know someone who uses python and his application is fairly slow, for the simplest of programs you have to package the exe with tons of files, it just seems like a hassle. If you are going to learn a different language to do it C# is the way to go. C# is the most similar to C++ as well ;)
|
| All times are GMT -5. The time now is 20:24. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi