Original Post
I have tryed to make a reguler exemple window. however i keep falling for my own error that sais, that if the window doesnt equal to window type defination dont register it, and also give error for it... i have no idea what`s wrong here, i am looking at this code for days and i am at a dead end...
//Mainwindow.cpp
//Main window defination
#define WIN32_LEAN_AND_MEAN
#define WINDOW_CLASS_NAME "WINCLASS1"
#include <windows.h>
#include <windowsx.h>
#include <stdio.h>
#include <math.h>
LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch(msg)
{
case WM_CREATE:
MessageBox(NULL, "Error Text",
"Header Text",
MB_OK);
break;
case VK_ESCAPE:
case WM_DESTROY:
case WM_QUIT:
PostQuitMessage(0);
break;
default:break;
}
return DefWindowProc(hwnd, msg, wparam, lparam);
}
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow)
{
WNDCLASSEX illawind;
HWND hwnd;
MSG msg;
illawind.lpfnWndProc = WindowProc;
illawind.cbClsExtra = sizeof(WNDCLASSEX);
illawind.hIcon = LoadIcon(NULL, IDI_WINLOGO);
illawind.hInstance = hinstance;
illawind.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
illawind.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
illawind.hCursor = LoadCursor(NULL, IDC_ARROW);
illawind.cbClsExtra = 0;
illawind.cbWndExtra = 0;
illawind.lpszMenuName = NULL;
illawind.lpszClassName = WINDOW_CLASS_NAME;
illawind.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
if(!RegisterClassEx(&illawind))
{
MessageBox(NULL,
"Unable To register window",
"Illa Error #1",
MB_OK);
}
return (0);
if(!(hwnd = CreateWindowEx(NULL,
"Ground Zero",
"Ground Zero",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
0, 0,
400, 400,
NULL,
NULL,
hinstance,
NULL)))
return (0);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (msg.wParam);
}