No matter what I do, it wont work. Here's the script..
Code:
#include <windows.h>
const char g_szClassName[] = "myClassWindow";
LRESULT CALLBACK WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT PaintStruct;
HDC hDC;
switch(Msg)
{
case WM_MBUTTONDOWN:
{ //<--- one of these...
Player PC;
PC.Age = 22;
MessageBox(NULL, Player.Age, "Message", MB_OK);
break;
} //<-- ... and another
case WM_PAINT: hDC = BeginPaint(hWnd, &PaintStruct);
TextOut(hDC, 10, 10, "Hi", 2);
EndPaint(hWnd, &PaintStruct);
break;
case WM_CLOSE: DestroyWindow(hWnd);
break;
case WM_DESTROY: PostQuitMessage(0);
break;
default: return DefWindowProc(hWnd, Msg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wc;
HWND hWnd;
MSG Msg;
// Registering Class Window
wc.cbClsExtra = 0;
wc.cbSize = sizeof(WNDCLASSEX);
wc.cbWndExtra = 0;
wc.hbrBackground = (HBRUSH) (COLOR_WINDOW+1);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
wc.hInstance = hInstance;
wc.lpfnWndProc = WndProc;
wc.lpszClassName = g_szClassName;
wc.lpszMenuName = NULL;
wc.style = 0;
if (!RegisterClassEx(&wc))
{
MessageBox(NULL, "Registering Class Failed!", "Message", MB_ICONEXCLAMATION | MB_OK);
return 0;
}
// Creating Window
hWnd = CreateWindowEx(WS_EX_CLIENTEDGE, g_szClassName, "World of Dragons", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL, NULL, hInstance, NULL);
if (hWnd == NULL)
{
MessageBox(NULL, "Creating Window Failed!", "Message", MB_ICONEXCLAMATION | MB_OK);
return 0;
}
// Misc, but not last...
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
while (GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
Header:
Code:
#include <iostream>
class Player
{
public:
unsigned short int Age;
};
And last, our bugs:
Code:
C:\Program Files\Microsoft Visual Studio\MyProjects\WIN32Pract2\Main.cpp(5) : error C2146: syntax error : missing ';' before identifier 'PC'
C:\Program Files\Microsoft Visual Studio\MyProjects\WIN32Pract2\Main.cpp(5) : error C2501: 'Player' : missing storage-class or type specifiers
C:\Program Files\Microsoft Visual Studio\MyProjects\WIN32Pract2\Main.cpp(5) : fatal error C1004: unexpected end of file found