🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Why won't the window display?
while(GetMessage()){ TranslateMessage(); DispatchMessage();}
That's just some quicky psuedocode so check the documentation.
Also, why did you comment out ShowWindow() and UpdateWindow()?
And, you should at least call DefWindowProc() in the WinProc procedure. This handles messages you don't.
And you can probably leave out main_window_handle and just use your hwnd var wherever you use it.
Good Luck
All I am doing is createing a basic window class, registering it and trying to display it. I get no complie errors, but when I run the .exe nothing happens...Why not, what am I missing?
-----------------------------------
//includes and defines
#define WIN32_LEAN_AND_MEAN
#include
#include
//windproc function
LRESULT CALLBACK WindowProc(HWND hwnd, //the window
UINT msg, //the message itself
WPARAM wParam,
LPARAM lParam)
{
return 0;
}
//winmain entry point
int WINAPI WinMain(HINSTANCE hinstance,
HINSTANCE hprevinstance,
LPSTR lpCmdLine,
int nShowCmd)
{
//declaration of window class
WNDCLASS wndclass;
HWND hwnd;
wndclass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WindowProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hinstance; //from winmain
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = "WINCLASS1";
//register wndclass
if (RegisterClass(&wndclass)==0)
{
//error
}
//create windows
HWND main_window_handle = NULL;
main_window_handle = CreateWindow("WINCLASS1",
"Blind Try",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
100, 100,
320, 200,
NULL,
NULL,
hinstance,
NULL);
hwnd = main_window_handle;
//show window
//ShowWindow(main_window_handle, SW_SHOW);
//UpdateWindow(main_window_handle);
return 0;
}
---------------------------------------
-Erik L. Elmore