Jump to content
  • Advertisement

Archived

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

Idhrendur

Registering a window class

This topic is 5210 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''ve had several programs now where I open a window, whatever. It''s basic. All of a sudden, I find myself unable to do that. A little debugging/testing, and I find that the window class isn''t being registered. So, I hunt down the error code. According to MSDN, the code means "The system cannot find the file specified." Which leaves me totally confused. My use of files had nothng to do with my registration, and there error doesn''t exist before I try to register the class. Anyways, I think I''ve rambeled enough. Here''s the pertinent code:
//prepare window

	this_time = hInstance;
	WNDCLASSEX main_window_struct;
	main_window_struct.cbClsExtra = 0;
	main_window_struct.cbSize = sizeof(WNDCLASSEX);
	main_window_struct.cbWndExtra = 0;
	main_window_struct.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
	main_window_struct.hCursor = LoadCursor(NULL, IDC_ARROW);
	main_window_struct.hIcon = LoadIcon(NULL, IDI_WINLOGO);
	main_window_struct.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
	main_window_struct.hInstance = this_time;
	main_window_struct.lpfnWndProc = &message_router;
	main_window_struct.lpszClassName = "Cloneness";
	main_window_struct.lpszMenuName = MAKEINTRESOURCE(MAIN_MENU);
	main_window_struct.style = NULL;
	RegisterClassEx(&main_window_struct);

	DWORD blah = GetLastError();
Any and all help is appreciated!

Share this post


Link to post
Share on other sites
Advertisement
The problem is the way you have declared the class name.

Try declaring a global char array as follows:

char class_name[MAX_PATH];

...in some initialisation section do...

strcpy(class_name, "Cloneness");

...and then...

main_window_struct.lpszClassName = class_name;

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!