Archived

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

Access violation when registering class (lesson 1)

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