Hello
I''ve gotten to make a window and use a menu system and all, but am trying to get this stuff into my head so I can stop referring to the simple tutorials.
In breakin gup the creation of a simple window for winprog. (which it does work, so I''n not complaining) :
I''ve extracted the register and create window procedures.
The program compiles, but when run, the "Window creation Failed" error activates.
What is essiantially required to make this program run ?
(Not display the window, just "run" without errors).
I''d just like to know how it works, instead of just memorizing code..
Wez
#include <windows.h>
const char g_szClassName[] = "myWindowClass";
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM
lparam)
{
return 0;
}
int WINAPI WinMain(HINSTANCE hinst, HINSTANCE hpinst, LPSTR cmdln, int
cmdshow)
{
WNDCLASSEX wc;
HWND hwnd;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_BYTEALIGNCLIENT;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hinst;
wc.hIcon = LoadIcon(NULL, IDI_EXCLAMATION);
wc.hCursor = LoadCursor(NULL, IDC_CROSS);
wc.hbrBackground= (HBRUSH) (COLOR_APPWORKSPACE);
wc.lpszMenuName = NULL;
wc.lpszClassName= g_szClassName;
wc.hIconSm = LoadIcon(NULL, IDI_EXCLAMATION);
if (!RegisterClassEx(&wc))
{
MessageBox(NULL,"window reg failed","err",MB_OK);
return 0;
}
hwnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
g_szClassName,
" - ? - ",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 240, 120,
NULL, NULL, hinst, NULL);
if (hwnd == NULL)
{
MessageBox(NULL, "Window Creation Failed","err", MB_OK);
return 0;
}
}
[/souce]