#include <windows.h>
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR szCmdLine, int nShowCmd)
{
static char name[] = "My Application";
WNDCLASSEX wc;
HWND hwnd;
MSG Msg;
//Step 1: Registering the Window Class
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH) (COLOR_WINDOW+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = name;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc))
{
MessageBox(NULL, TEXT("Window Registration Failed!"), TEXT("Registration Failure"),
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
// Step 2: Creating the Window
hwnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
name,
"My First Window",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 400, 400,
NULL, NULL, hInstance, NULL);
ShowWindow(hwnd, nShowCmd);
UpdateWindow(hwnd);
// Step 3: The Message Loop
while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return (int)Msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
I'm getting the following errors building it, though. Maybe someone can look at it, and see what I'm missing here.
Errors:
Error 1 error C2440: '=' : cannot convert from 'char [15]' to 'LPCWSTR' c:\users\marcus\documents\visual studio 2010\projects\myfirstwindow\myfirstwindow\myfirstwindow.cpp 24
Error 2 error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'char [15]' to 'LPCWSTR' c:\users\marcus\documents\visual studio 2010\projects\myfirstwindow\myfirstwindow\myfirstwindow.cpp 41
3 IntelliSense: a value of type "char *" cannot be assigned to an entity of type "LPCWSTR" c:\users\marcus\documents\visual studio 2010\projects\myfirstwindow\myfirstwindow\myfirstwindow.cpp 24
4 IntelliSense: argument of type "char *" is incompatible with parameter of type "LPCWSTR" c:\users\marcus\documents\visual studio 2010\projects\myfirstwindow\myfirstwindow\myfirstwindow.cpp 37
5 IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR" c:\users\marcus\documents\visual studio 2010\projects\myfirstwindow\myfirstwindow\myfirstwindow.cpp 38

New Topic/Question
Reply



MultiQuote






|