• Advertisement
Sign in to follow this  

A Win32 problem

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

First off its late and I am tried so sorry in advance if this is hard to understand. Now the problem. I am trying to create a window, something I have done tons of times before, however for some reason this time I get an error message I have never seen before. To make it short no window comes up and I find out that RegisterClassEx() is failing so I use GetLastError() and it returns ERROR_FILE_NOT_FOUND which makes no sense since I am not using any files for RegisterClassEx(). below is a code snippit.

	ZeroMemory(&ToolWindowClass, sizeof(WNDCLASSEX));
	

	ToolWindowClass.cbSize			= sizeof(WNDCLASSEX);
	ToolWindowClass.lpfnWndProc		= (WNDPROC)wndproc;
	ToolWindowClass.lpszClassName	= L"Tool Window Class";
	ToolWindowClass.hInstance		= MainInstance;
	ToolWindowClass.style			= CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;

	RegisterClassEx(&ToolWindowClass);


Now wndproc is a valid windows procedure, and since this is to be a child window MainInstance if the hInstance of the application. Has anyone gotten a ERROR_FILE_NOT_FOUND error from RegisterClassEx() before? Personaly it makes no sense to me and when I saw that message the first words out of my mouth was WTF!!!!!!!!! Anyways I am at a total loss as to what could possably be the problem on this and really need help.

Share this post


Link to post
Share on other sites
Advertisement
Can you post your WndProc, as well as the exact code you're using when you call GetLastError? (Specifically, include context - are you calling GetLastError immediately after RegisterClassEx, etc.)

Share this post


Link to post
Share on other sites
Are you sure the RegisterClassEx is the function that is failing? I just tried something similar, and GetLastError prior to RegisterClassEx returned 0, then ERROR_FILE_NOT_FOUND after RegisterClassEx. But even though it returned ERROR_FILE_NOT_FOUND, the return value of RegisterClassEx was non-zero, which meant that it succeeded...

J

Share this post


Link to post
Share on other sites
Have you tried it with the entire WNDCLASSEX structure filled out?

Also, why explicitly stipulate a unicode class name without explicitly stipulating the "W" versions of the WNDCLASSEX structure and RegisterClassEx?

ToolWindowClass.lpszClassName = L"Tool Window Class";

Rather than change the struct and the funk, it would be easier to wrap that string literal with the TEXT or _T macros. You might have to include tchar.h.

ToolWindowClass.lpszClassName = TEXT("Tool Window Class");


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement