Go to Post I tell my friends that the robot is the kids product and the kids are the mentors product. - rwood359 [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 13-12-2007, 18:12
slavik262's Avatar
slavik262 slavik262 is offline
We do what we must because we can.
AKA: Matt Kline
FRC #0537 (Charger Robotics)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Sussex, WI
Posts: 310
slavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to behold
Send a message via AIM to slavik262
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?
__________________
  #2   Spotlight this post!  
Unread 13-12-2007, 19:22
Pat Fairbank's Avatar
Pat Fairbank Pat Fairbank is offline
Circuit Breaker
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2001
Location: San Jose, CA
Posts: 2,131
Pat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond repute
Send a message via MSN to Pat Fairbank
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.
__________________
Patrick Fairbank
Team 254 | Mentor (2012-)
Team 1503 | Mentor (2007-2011)
Team 296 | Alumnus (2001-2004) | Mentor (2005-2006)

patfairbank.com
  #3   Spotlight this post!  
Unread 13-12-2007, 19:34
Bomberofdoom's Avatar
Bomberofdoom Bomberofdoom is offline
Biggest FIRST addict in Israel
AKA: Nir Levanon
FRC #2230 (Zcharia's Angels)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Israel
Posts: 471
Bomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond repute
Send a message via MSN to Bomberofdoom
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.
__________________
TEAM 2230 ZECHARIA'S ANGELS

2009 Microsoft Israel FRC Regional Winners!
2009 Microsoft Israel FRC Regional Chairman's Award Winners!!!
---------------------------------
2008 Microsoft Israel FRC Regional semi-finalist.
2008 Microsoft Israel FRC Regional Delphi's "Driving Tommorow's Technology" Award winner.
2008 Robot Driver
---------------------------------
2007 GM/Technion Israel FRC Regional semi-Finalist.
2007 GM/Technion Israel FRC Regional Xerox Creativity Award winner.
2007 Robot Driver.
  #4   Spotlight this post!  
Unread 13-12-2007, 19:47
tajmorton tajmorton is offline
Registered User
FRC #0847 (PHRED)
Team Role: College Student
 
Join Date: Nov 2007
Rookie Year: 2008
Location: Philomath, OR
Posts: 10
tajmorton is a jewel in the roughtajmorton is a jewel in the roughtajmorton is a jewel in the roughtajmorton is a jewel in the rough
Send a message via AIM to tajmorton
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
  #5   Spotlight this post!  
Unread 13-12-2007, 21:00
bear24rw's Avatar
bear24rw bear24rw is offline
Team 11 Programming Captain
AKA: Max T
FRC #0011 (MORT)
Team Role: Programmer
 
Join Date: Sep 2005
Rookie Year: 2005
Location: Flanders, NJ
Posts: 385
bear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to behold
Send a message via AIM to bear24rw
Re: Creating Windows GUIs with C++

Also check out wxWidgets
  #6   Spotlight this post!  
Unread 13-12-2007, 21:21
slavik262's Avatar
slavik262 slavik262 is offline
We do what we must because we can.
AKA: Matt Kline
FRC #0537 (Charger Robotics)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Sussex, WI
Posts: 310
slavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to behold
Send a message via AIM to slavik262
Re: Creating Windows GUIs with C++

Awesome guys. Thanks for the help.
__________________
  #7   Spotlight this post!  
Unread 19-12-2007, 23:27
wt200999's Avatar
wt200999 wt200999 is offline
Texas Instruments
AKA: Will Toth
FRC #3005 (Robochargers)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2004
Location: Dallas, Texas
Posts: 323
wt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud of
Send a message via MSN to wt200999
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
  #8   Spotlight this post!  
Unread 19-12-2007, 23:39
shawger shawger is offline
Programming Subteam Leader
FRC #1732 (Hilltopper Robotics)
Team Role: Alumni
 
Join Date: Nov 2006
Rookie Year: 2006
Location: Wisconsin
Posts: 60
shawger will become famous soon enough
Re: Creating Windows GUIs with C++

Quote:
Originally Posted by wt200999
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.
To clarify, Qt is dual-licensed under a commercial license as well as the GPL. If you use Qt to develop a program under the terms of the GPL, than you may use the free (cost) GPL Qt. If you are developing closed-source programs, than you will have to pay for the commercial license of Qt.

Last edited by shawger : 19-12-2007 at 23:41.
  #9   Spotlight this post!  
Unread 20-12-2007, 18:03
slavik262's Avatar
slavik262 slavik262 is offline
We do what we must because we can.
AKA: Matt Kline
FRC #0537 (Charger Robotics)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Sussex, WI
Posts: 310
slavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to behold
Send a message via AIM to slavik262
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>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
				   LPSTR lpCmdLine, int nShowCmd)
{
	MessageBox(NULL, "Hello!", 
		"Hello World", MB_OK | MB_ICONINFORMATION);
	if (MessageBox(NULL, "I'm learning to use C++ to write native Windows programs.  Cool, isn't it?",
		"Cool, No?", MB_YESNO | MB_ICONQUESTION) == IDYES)
		MessageBox(NULL, "You know it!", "Sweet!", MB_OK);
	else MessageBox(NULL, "Jerk.", "Grrr", MB_OK);
	return 0;
}
I'm using Microsoft Visual Studio C++ Express Edition 2008 as my IDE.

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:
error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [13]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
I've tried using the Windows.h that came with the IDE and one I got from Windows Platform SDK for Windows Server 2003 R2.
__________________

Last edited by slavik262 : 20-12-2007 at 18:27.
  #10   Spotlight this post!  
Unread 20-12-2007, 18:35
Pat Fairbank's Avatar
Pat Fairbank Pat Fairbank is offline
Circuit Breaker
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2001
Location: San Jose, CA
Posts: 2,131
Pat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond repute
Send a message via MSN to Pat Fairbank
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>

...

// This is a string of 256 characters (ASCII or wide)
TCHAR szText[256]; 

...

// _T and _TEXT do the same thing
MessageBox(NULL, _T("Hello!"), 
	_TEXT("Hello World"), MB_OK | MB_ICONINFORMATION);
If you plan to use standard string functions (like strcpy, strcmp, etc.) there are TCHAR equivalents (like _tcsncpy and _tcsncmp) that will be converted to the appropriate function by the preprocessor at compile time - just look them up in tchar.h.
__________________
Patrick Fairbank
Team 254 | Mentor (2012-)
Team 1503 | Mentor (2007-2011)
Team 296 | Alumnus (2001-2004) | Mentor (2005-2006)

patfairbank.com

Last edited by Pat Fairbank : 20-12-2007 at 18:37.
  #11   Spotlight this post!  
Unread 20-12-2007, 22:06
slavik262's Avatar
slavik262 slavik262 is offline
We do what we must because we can.
AKA: Matt Kline
FRC #0537 (Charger Robotics)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Sussex, WI
Posts: 310
slavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to behold
Send a message via AIM to slavik262
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:
this application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem.
My code:
Code:
#include <Windows.h>
#include <tchar.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
				   LPSTR lpCmdLine, int nShowCmd)
{
	MessageBox(NULL, _T("Hello!"), 
		_T("Hello World"), MB_OK | MB_ICONINFORMATION);
	if (MessageBox(NULL, _T("I'm learning to use C++ to write native Windows programs.  Cool, isn't it?"),
		_T("Cool, No?"), MB_YESNO | MB_ICONQUESTION) == IDYES)
		MessageBox(NULL, _T("You know it!"), _T("Sweet!"), MB_OK);
	else MessageBox(NULL, _T("Jerk."), _T("Grrr"), MB_OK);
	return 0;
}
__________________
  #12   Spotlight this post!  
Unread 20-12-2007, 22:46
Pat Fairbank's Avatar
Pat Fairbank Pat Fairbank is offline
Circuit Breaker
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2001
Location: San Jose, CA
Posts: 2,131
Pat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond repute
Send a message via MSN to Pat Fairbank
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.
__________________
Patrick Fairbank
Team 254 | Mentor (2012-)
Team 1503 | Mentor (2007-2011)
Team 296 | Alumnus (2001-2004) | Mentor (2005-2006)

patfairbank.com
  #13   Spotlight this post!  
Unread 20-12-2007, 22:52
slavik262's Avatar
slavik262 slavik262 is offline
We do what we must because we can.
AKA: Matt Kline
FRC #0537 (Charger Robotics)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Sussex, WI
Posts: 310
slavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to behold
Send a message via AIM to slavik262
Re: Creating Windows GUIs with C++

It gets better and better.
__________________
  #14   Spotlight this post!  
Unread 20-12-2007, 23:28
TimCraig TimCraig is offline
Registered User
AKA: Tim Craig
no team
 
Join Date: Aug 2004
Rookie Year: 2003
Location: San Jose, CA
Posts: 221
TimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to behold
Re: Creating Windows GUIs with C++

Quote:
Originally Posted by slavik262 View Post
It gets better and better.
While the fundamentals of writing Windows applications is relatively straightforward, it's all the arcane gotchas that take a long time to come across and learn so you can be really good. If you're looking for a C++ framework, I'd go with MFC to start. There's good Wizard support in Visual Studio and lots of help available on the Web. There are literally thousands of examples to be had. www.codeproject.com is a very good source of both information and examples. One comment about examples though, the ones provided directly by Microsoft are horrible and you'd be better off never looking at them.

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.
  #15   Spotlight this post!  
Unread 21-12-2007, 10:07
slavik262's Avatar
slavik262 slavik262 is offline
We do what we must because we can.
AKA: Matt Kline
FRC #0537 (Charger Robotics)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Sussex, WI
Posts: 310
slavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to behold
Send a message via AIM to slavik262
Re: Creating Windows GUIs with C++

So much for being able to distribute just my executable.

However, I really appreciate you guys. Awesome help. This really shows how awesome FIRST (and CD) are.
__________________

Last edited by slavik262 : 21-12-2007 at 10:10.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is easyC compatible with windows vista team877 Programming 10 12-02-2007 12:43
What to do with an old Windows 3.10 laptop? Elgin Clock IT / Communications 13 14-07-2005 17:45
Prob. With Windows 2k Staz Programming 2 15-01-2005 10:15
Creating no pressure with double solenoid? Combat Chuck Pneumatics 7 29-02-2004 22:45
Need Help With Windows Applications In C++ Hailfire Programming 9 05-01-2003 10:13


All times are GMT -5. The time now is 09:31.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi