View Single Post
  #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.