Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Why won't the window display?

This topic is 6875 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The biggest reason is because you have no message loop. The program creates the window and then quits. You need to pass messages from WinMain() to the WinProc() through the message loop. this is usually(except for games ) a while loop like:


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

Share this post

Link to post
Share on other sites
The BIGGEST problem IS the message loop, but still the window will not display if you dont process the WM_PAINT message. Look it up in Petzold. (or MSDN / LaMothe).

-Erik L. Elmore

Share this post

Link to post
Share on other sites
Hi, below is some source code in c++.
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

//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.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)

//create windows
HWND main_window_handle = NULL;
main_window_handle = CreateWindow("WINCLASS1",
"Blind Try",
100, 100,
320, 200,

hwnd = main_window_handle;

//show window
//ShowWindow(main_window_handle, SW_SHOW);
return 0;



Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!