Click here to Skip to main content
15,949,686 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to convert LPCTSTR for MessageBox Function Pin
Chris Losinger14-Jul-09 10:05
professionalChris Losinger14-Jul-09 10:05 
AnswerRe: How to convert LPCTSTR for MessageBox Function Pin
Michael Schubert14-Jul-09 12:49
Michael Schubert14-Jul-09 12:49 
AnswerRe: How to convert LPCTSTR for MessageBox Function Pin
David Crow14-Jul-09 16:08
David Crow14-Jul-09 16:08 
QuestionNewbie question, problem compiling Pin
Adassus14-Jul-09 8:19
Adassus14-Jul-09 8:19 
QuestionRe: Newbie question, problem compiling Pin
Roger Stoltz14-Jul-09 8:29
Roger Stoltz14-Jul-09 8:29 
AnswerRe: Newbie question, problem compiling Pin
Randor 14-Jul-09 9:28
professional Randor 14-Jul-09 9:28 
AnswerRe: Newbie question, problem compiling Pin
Maximilien14-Jul-09 9:30
Maximilien14-Jul-09 9:30 
AnswerRe: Newbie question, problem compiling Pin
Adassus14-Jul-09 11:41
Adassus14-Jul-09 11:41 
this is a copy paste I got from an online tutorial. It compiles fine in codeblocks but gives me an error when I try to compile in visual c++.


The error is:


1>c:\documents and settings\john\my documents\visual studio 2008\projects\test\test\main.cpp(18) : error C2440: '=' : cannot convert from 'const char [13]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\documents and settings\john\my documents\visual studio 2008\projects\test\test\main.cpp(28) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [29]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\documents and settings\john\my documents\visual studio 2008\projects\test\test\main.cpp(42) : error C2664: 'CreateWindowExW' : 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
1>c:\documents and settings\john\my documents\visual studio 2008\projects\test\test\main.cpp(51) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [23]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>Build log was saved at "file://c:\Documents and Settings\john\My Documents\Visual Studio 2008\Projects\test\test\Debug\BuildLog.htm"
1>test - 4 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



#include <windows.h>

LRESULT CALLBACK WinProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam);

int WINAPI WinMain(HINSTANCE hInst,HINSTANCE hPrevInst,LPSTR lpCmdLine,int nShowCmd)
{
	WNDCLASSEX wClass;
	ZeroMemory(&wClass,sizeof(WNDCLASSEX));
	wClass.cbClsExtra=NULL;
	wClass.cbSize=sizeof(WNDCLASSEX);
	wClass.cbWndExtra=NULL;
	wClass.hbrBackground=(HBRUSH)COLOR_WINDOW;
	wClass.hCursor=LoadCursor(NULL,IDC_ARROW);
	wClass.hIcon=NULL;
	wClass.hIconSm=NULL;
	wClass.hInstance=hInst;
	wClass.lpfnWndProc=(WNDPROC)WinProc;
	wClass.lpszClassName="Window Class";
	wClass.lpszMenuName=NULL;
	wClass.style=CS_HREDRAW|CS_VREDRAW;

	if(!RegisterClassEx(&wClass))
	{
		int nResult=GetLastError();
		MessageBox(NULL,
			"Window class creation failed",
			"Window Class Failed",
			MB_ICONERROR);
	}

	HWND hWnd=CreateWindowEx(NULL,
			"Window Class",
			"Windows application",
			WS_OVERLAPPEDWINDOW,
			200,
			200,
			640,
			480,
			NULL,
			NULL,
			hInst,
			NULL);

	if(!hWnd)
	{
		int nResult=GetLastError();

		MessageBox(NULL,
			"Window creation failed",
			"Window Creation Failed",
			MB_ICONERROR);
	}

	ShowWindow(hWnd,nShowCmd);

	MSG msg;
	ZeroMemory(&msg,sizeof(MSG));

	while(GetMessage(&msg,NULL,0,0))
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	return 0;
}

LRESULT CALLBACK WinProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
	switch(msg)
	{
		case WM_DESTROY:
		{
			PostQuitMessage(0);
			return 0;
		}
		break;
	}

	return DefWindowProc(hWnd,msg,wParam,lParam);
}

GeneralRe: Newbie question, problem compiling Pin
Randor 14-Jul-09 11:59
professional Randor 14-Jul-09 11:59 
GeneralRe: Newbie question, problem compiling Pin
Adassus14-Jul-09 15:44
Adassus14-Jul-09 15:44 
QuestionUSB interaction from user space. I need some light please! Pin
sinosoidal14-Jul-09 6:32
sinosoidal14-Jul-09 6:32 
AnswerRe: USB interaction from user space. I need some light please! Pin
Roger Stoltz14-Jul-09 6:59
Roger Stoltz14-Jul-09 6:59 
AnswerRe: USB interaction from user space. I need some light please! Pin
Randor 14-Jul-09 8:41
professional Randor 14-Jul-09 8:41 
GeneralRe: USB interaction from user space. I need some light please! Pin
sinosoidal15-Jul-09 0:49
sinosoidal15-Jul-09 0:49 
GeneralRe: USB interaction from user space. I need some light please! Pin
Randor 15-Jul-09 8:08
professional Randor 15-Jul-09 8:08 
GeneralRe: USB interaction from user space. I need some light please! Pin
sinosoidal15-Jul-09 9:34
sinosoidal15-Jul-09 9:34 
QuestionProblem with the reading of the BMP file Pin
TeslaShock14-Jul-09 5:27
TeslaShock14-Jul-09 5:27 
AnswerRe: Problem with the reading of the BMP file Pin
Chris Losinger14-Jul-09 6:01
professionalChris Losinger14-Jul-09 6:01 
GeneralRe: Problem with the reading of the BMP file Pin
TeslaShock14-Jul-09 6:13
TeslaShock14-Jul-09 6:13 
AnswerRe: Problem with the reading of the BMP file Pin
Joe Woodbury14-Jul-09 6:38
professionalJoe Woodbury14-Jul-09 6:38 
GeneralRe: Problem with the reading of the BMP file Pin
TeslaShock16-Jul-09 5:13
TeslaShock16-Jul-09 5:13 
QuestionOnInitDialog() never be called Pin
transoft14-Jul-09 2:22
transoft14-Jul-09 2:22 
QuestionRe: OnInitDialog() never be called Pin
CPallini14-Jul-09 2:35
mveCPallini14-Jul-09 2:35 
AnswerRe: OnInitDialog() never be called Pin
transoft14-Jul-09 2:42
transoft14-Jul-09 2:42 
GeneralRe: OnInitDialog() never be called Pin
Cedric Moonen14-Jul-09 2:48
Cedric Moonen14-Jul-09 2:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.