-
What is wrong here???
I have compiled the following code successfully a few times, but then I started some weird error???!!
Here is the code:
Code:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
#define WINDOW_CLASS_NAME " WINCLASS1"
HWND main_window_handle = NULL;
LRESULT CALLBACK WindowProc(HWND hwnd,
UINT msg,
WPARAM wparam,
LPARAM lparam)
{
PAINTSTRUCT ps;
HDC hdc;
switch(msg)
{
case WM_CREATE:
{
return 0;
} break;
case WM_PAINT:
{
hdc = BeginPaint(hwnd, &ps);
EndPaint(hwnd, &ps);
return 0;
} break;
case WM_DESTROY:
{
MessageBox(NULL, "Bye bye cruel world!", "Bye!", MB_OK | MB_ICONINFORMATION);
PostQuitMessage(0);
return 0;
} break;
default: break;
}
return (DefWindowProc(hwnd, msg, wparam, lparam));
}
int WINAPI WinMain(HINSTANCE hinstance,
HINSTANCE hPrevInstance,
LPSTR lpstCmdLine, int ncmdshow)
{
WNDCLASS winclass;
HWND hwnd;
MSG msg;
winclass.style = CS_DBLCLKS | CS_OWNDC |
CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc = WindowProc;
winclass.cbClsExtra = 0;
winclass.cbWndExtra = 0;
winclass.hInstance = hinstance;
winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
winclass.hCursor = LoadCursor(NULL, IDC_ARROW);
winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.lpszMenuName = NULL;
winclass.lpszClassName = WINDOW_CLASS_NAME;
if (!RegisterClass(&winclass))
return 0;
if (!(hwnd = CreateWindow(WINDOW_CLASS_NAME, "Hello Carsten!",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
350,200,
320,200,
NULL,
NULL;
hinstance,
NULL)))
return 0;
main_window_handle = hwnd;
while (1)
{
if (PeekMessage(&msg, NULL, 0,0, PM_REMOVE))
{
if (msg.message == WM_QUIT) break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return(msg.wParam);
}
Here are the errors:
--------------------Configuration: Win32Training - Win32 Debug--------------------
Compiling...
file.cpp
c:\programmer\microsoft visual studio\myprojects\win32training\file.cpp(75) : warning C4003: not enough actual parameters for macro 'CreateWindowA'
c:\programmer\microsoft visual studio\myprojects\win32training\file.cpp(75) : error C2143: syntax error : missing ')' before ';'
c:\programmer\microsoft visual studio\myprojects\win32training\file.cpp(75) : error C2660: 'CreateWindowExA' : function does not take 10 parameters
c:\programmer\microsoft visual studio\myprojects\win32training\file.cpp(75) : error C2143: syntax error : missing ')' before ';'
c:\programmer\microsoft visual studio\myprojects\win32training\file.cpp(75) : error C2143: syntax error : missing ')' before ';'
c:\programmer\microsoft visual studio\myprojects\win32training\file.cpp(75) : warning C4390: ';' : empty controlled statement found; is this the intent?
c:\programmer\microsoft visual studio\myprojects\win32training\file.cpp(75) : error C2059: syntax error : ')'
c:\programmer\microsoft visual studio\myprojects\win32training\file.cpp(75) : error C2059: syntax error : ')'
c:\programmer\microsoft visual studio\myprojects\win32training\file.cpp(75) : error C2059: syntax error : ')'
c:\programmer\microsoft visual studio\myprojects\win32training\file.cpp(76) : error C2059: syntax error : 'return'
Error executing cl.exe.
Win32Training.exe - 8 error(s), 2 warning(s)
-
Never mind guys! A few ',' did the trick! :D