My first Win32 program...
-
Following is the code of my program...
#include "stdafx.h"
#include "windows.h"int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
MessageBox(NULL, "This is my first windows program\n Author: Mohsin", "Virtual University", MB_OK|MB_ICONINFORMATION);
}While building it is throwing following error..
Error 1 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [49]' to 'LPCWSTR' e:\visual programming\practices\test\test\p_66.cpp 6 test
Mohsin Ali
-
Following is the code of my program...
#include "stdafx.h"
#include "windows.h"int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
MessageBox(NULL, "This is my first windows program\n Author: Mohsin", "Virtual University", MB_OK|MB_ICONINFORMATION);
}While building it is throwing following error..
Error 1 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [49]' to 'LPCWSTR' e:\visual programming\practices\test\test\p_66.cpp 6 test
Mohsin Ali
It is because UNICODE is defined. If you want a full understanding, a strongly suggest this article[^].
Cédric Moonen Software developer
Charting control [v1.4] -
Following is the code of my program...
#include "stdafx.h"
#include "windows.h"int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
MessageBox(NULL, "This is my first windows program\n Author: Mohsin", "Virtual University", MB_OK|MB_ICONINFORMATION);
}While building it is throwing following error..
Error 1 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [49]' to 'LPCWSTR' e:\visual programming\practices\test\test\p_66.cpp 6 test
Mohsin Ali
It happens because the project is built for UNICODE.
Sudhir Kumar
-
Following is the code of my program...
#include "stdafx.h"
#include "windows.h"int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
MessageBox(NULL, "This is my first windows program\n Author: Mohsin", "Virtual University", MB_OK|MB_ICONINFORMATION);
}While building it is throwing following error..
Error 1 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [49]' to 'LPCWSTR' e:\visual programming\practices\test\test\p_66.cpp 6 test
Mohsin Ali
In build toolbar select Win32 Release or Win32 debug.
Sudhir Kumar
-
It happens because the project is built for UNICODE.
Sudhir Kumar
-
Following is the code of my program...
#include "stdafx.h"
#include "windows.h"int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
MessageBox(NULL, "This is my first windows program\n Author: Mohsin", "Virtual University", MB_OK|MB_ICONINFORMATION);
}While building it is throwing following error..
Error 1 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [49]' to 'LPCWSTR' e:\visual programming\practices\test\test\p_66.cpp 6 test
Mohsin Ali
Use of this MessageBox(NULL, _T("This is my first windows program\n Author: Mohsin"), _T("Virtual University"), ...
-
Then how can I change... I mean what I have to do in order to remove this error..
Mohsin Ali
Use generic text mappings instead of using char arrays. This way if you want to enable UNICODE later on, your program will support it.
Cédric Moonen Software developer
Charting control [v1.4] -
Following is the code of my program...
#include "stdafx.h"
#include "windows.h"int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
MessageBox(NULL, "This is my first windows program\n Author: Mohsin", "Virtual University", MB_OK|MB_ICONINFORMATION);
}While building it is throwing following error..
Error 1 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [49]' to 'LPCWSTR' e:\visual programming\practices\test\test\p_66.cpp 6 test
Mohsin Ali
Did you got any success with these replyes.
Sudhir Kumar
-
Following is the code of my program...
#include "stdafx.h"
#include "windows.h"int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
MessageBox(NULL, "This is my first windows program\n Author: Mohsin", "Virtual University", MB_OK|MB_ICONINFORMATION);
}While building it is throwing following error..
Error 1 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [49]' to 'LPCWSTR' e:\visual programming\practices\test\test\p_66.cpp 6 test
Mohsin Ali
change you code into the following. and in a general mean, always use
_T()
around you literal strings to avoid to matter whether Unicode is defined or not :#include "stdafx.h"
#include "windows.h"int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
MessageBox(
NULL,
**_T(**
"This is my first windows program\n Author: Mohsin"**)**
,
**_T(**
"Virtual University"**)**
,
MB_OK|MB_ICONINFORMATION);
}[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
-
It happens because the project is built for UNICODE.
Sudhir Kumar
Sorry but I will complain about the answering style of some people. For example in this question it is obvious that he is a newbie and facing a simple problem. But look at the answers to that simple question. Its because you are in UNICODE...... is this the answer? Think about the person expecting a solution : so what? What am I supposed to do? Where should I read? Would not it be better if you answer it in such a way. (like the way
toxcct
did for example) It's because of ......, You should try a code like ......, For more info you can read .... web page At the top of the forum there is a default subject "How to get an answer to your question" and I think there should be another one "HOW TO ANSWER A QUESTION". -
Sorry but I will complain about the answering style of some people. For example in this question it is obvious that he is a newbie and facing a simple problem. But look at the answers to that simple question. Its because you are in UNICODE...... is this the answer? Think about the person expecting a solution : so what? What am I supposed to do? Where should I read? Would not it be better if you answer it in such a way. (like the way
toxcct
did for example) It's because of ......, You should try a code like ......, For more info you can read .... web page At the top of the forum there is a default subject "How to get an answer to your question" and I think there should be another one "HOW TO ANSWER A QUESTION".zafersavas wrote:
Its because you are in UNICODE...... is this the answer? Think about the person expecting a solution : so what? What am I supposed to do? Where should I read?
That would be a good enough clue for most. At this point, the OP simply needs to do this.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne