954,504 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Problem with Win32 Message Box

#ifdef _WIN32
#include <windows.h>
#endif
#include <iostream>
#include <vector>
#include <string>
#include <SDL/SDL.h>
#include <GL/gl.h>
#include <GL/glu.h>

using std::vector;

void error(const std::string& s) {
#ifdef _WIN32
	MessageBox(NULL, s.c_str(), "An error occurred", MB_ICONINFORMATION | MB_OK);
#else
	std::cerr << s << std::endl;
#endif
}

That's my problem...

1>------ Build started: Project: glut_1, Configuration: Debug Win32 ------
1>  main.cpp
1>c:\users\konnor\documents\visual studio 2010\projects\glut_1\glut_1\main.cpp(15): error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char *' to 'LPCWSTR'
1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

And there's the error. Not sure what to do. Thanks in advance.

Khoanyneosr
Junior Poster in Training
61 posts since Mar 2011
Reputation Points: 10
Solved Threads: 0
 

You working with a project where
#define UNICODE
is defined ,

If you want to continue with your UNICODE way, then I suggest you to typecast
your asci to unicode.

use any trick in here,
http://social.msdn.microsoft.com/Forums/en/Vsexpressvc/thread/0f749fd8-8a43-4580-b54b-fbf964d68375

NicAx64
Posting Pro
536 posts since Mar 2009
Reputation Points: 86
Solved Threads: 44
 

You working with a project where #define UNICODE is defined ,

If you want to continue with your UNICODE way, then I suggest you to typecast your asci to unicode.

use any trick in here, http://social.msdn.microsoft.com/Forums/en/Vsexpressvc/thread/0f749fd8-8a43-4580-b54b-fbf964d68375

Alright, so don't really know what the differences between multi-byte code and unicode. How do i make it work? I looked over the last post and It just flew right over my head.
Thank you very much for the response though.

Khoanyneosr
Junior Poster in Training
61 posts since Mar 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: