Jump to content
  • Advertisement

Archived

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

nimgus

Access violation when registering class (lesson 1)

This topic is 5458 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 made the first lesson but when I ran the program I got an access violation at the following line: if(!RegisterClass(&wc)) { MessageBox(NULL, "Failed To Register The Window Class.", "ERROR", MB_OK | MB_ICONEXCLAMATION); return FALSE; } How can this be? I use MSVS.net. Also there is an error in the Autos (which I don''t understand at all and I don''t know if this helps you): name: wc.lpszClassName value: 0x00429040 "OpenGL" type: const char * Further on I get a warning that there is a possible loss of data when returning wParam in the WinMain function. Is this right? nimgus, the another way

Share this post


Link to post
Share on other sites
Advertisement
1) Show us the code you use to build your WNDCLASS structure, it may be failing because of one of those inputs (as it often is).

2) Your somewhat supposed to return the wParam of the message when exiting from WinMain, but that doesn''t cause "data loss"...I''m not sure what you mean here.

Share this post


Link to post
Share on other sites
Most likely that `wc'' is not a valid variable. It probably has a member that is supposed to be pointing to something valid, but does the opposite.

Share this post


Link to post
Share on other sites
WNDCLASS wc; // windows class structure

wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // redraw on move, and own DC for window
wc.lpfnWndProc = (WNDPROC) WndProc; // WndProc handles messages
wc.cbClsExtra = 0; // no extra window data
wc.cbWndExtra = 0; // no extra window data
wc.hInstance = hInstance; // set the instance
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); // load the default icon
wc.hbrBackground = NULL; // no background required for GL
wc.lpszClassName = "OpenGL"; // set the class name



I''m not really sure what the data loss of wParam is about either. Sometimes this error doesn''t even show up.

nimgus, the another way

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
ur missing:

wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.lpszMenuName = NULL;

And even if ur not going to use them, you still need to set them to NULL..

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!