Jump to content
  • Advertisement

Archived

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

Promit

What can cause CreateWindowEx to fail?

This topic is 6115 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

I think I''m making a silly mistake, only I don''t exactly know what it IS. Here''s the relevant line: m_hWnd = CreateWindowEx( NULL, Name, Name, dwExStyle, CW_USEDEFAULT, CW_USEDEFAULT, Width, Height, NULL, NULL, hInstance, NULL ); hInstance is valid, Name is just a pointer to a char array, Width and Height are typical int''s, and dwExStyle is just a DWORD that equals WS_OVERLAPPEDWINDOW. I can''t see why this should fail, but m_hWnd keeps coming out NULL. ANy ideas? ----------------------------- The sad thing about artificial intelligence is that it lacks artifice and therefore intelligence.

Share this post


Link to post
Share on other sites
Advertisement
You also set your window class to be Name. I doubt you've actually registered a Window class with that name. Also, although the value WS_OVERLAPPEDWINDOW is correct (so it won't be the cause of this problem), that position is actually the style, not the extended style. Finally, the second CW_USEDEFAULT isn't necessary.

Try something like this:

    
LRESULT CALLBACK MyWndProc (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
return DefWindowProc (hWnd, Msg, wParam, lParam);
}

WNDCLASS wc;
ZeroMemory (&wc, sizeof (wc));
wc.lpfnWndProc = (WNDPROC)MyWndProc;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
wc.lpszClassName = "MYWINDOW";
RegisterClass (&wc);

DWORD dwStyle = WS_OVERLAPPEDWINDOW;
DWORD dwExStyle = 0;

m_hWnd = CreateWindowEx (dwExStyle, "MYWINDOW", Name, dwStyle, CW_USEDEFAULT, 0, Width, Height, NULL, NULL, hInstance, NULL);



Edited by - Kippesoep on December 29, 2001 7:32:40 PM

Share this post


Link to post
Share on other sites
I got it. Wasnt the RegisterClassEx, i checked that first. Turns out that I forgot to set the wc.hInstance to hInstance. Seems kind of redundant to set it twice...anywayz, it was just a silly mistake like i said. I noticed that I put the dxExStyle in the wrong spot, that was sposed t be named dwStyle, then a dwExStyle elsewheres....oh well. I got my prob solved.

-----------------------------
The sad thing about artificial intelligence is that it lacks artifice and therefore intelligence.

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!