Hello.
When I try to register my windows class using RegisterClassEx in my program
I get an error which GetLastError tells me is error 120.
This apparently is:
This function is not supported on this system.
I find this confusing as an identical call in one of the programs in the SDK
samples works fine? The only difference between the two is that my project is
built using UNICODE. Could this affect the outcome of function calls with
identical input?
This is the code:
LRESULT WINAPI MsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_PAINT:
case WM_TIMER:
case WM_GRAPHNOTIFY:
case WM_LBUTTONDOWN:
case WM_NEXTSCREEN:
case WM_STARTSCREEN:
HandleEvent(msg, wParam, lParam);
break;
case WM_DISPLAYCHANGE:
break;
case WM_CHAR:
{
if(wParam == VK_ESCAPE)
{
PostMessage(hWnd, WM_CLOSE, 0, 0);
}
else
{
PostMessage(hWnd, WM_NEXTSCREEN, 0, 0);
}
}
break;
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}
HRESULT MakeWindow(HINSTANCE hInstance)
{
WNDCLASSEX wc = {sizeof(WNDCLASSEX),
CS_CLASSDC,
MsgProc,
0L,
GetModuleHandle(NULL),
NULL,
NULL,
NULL,
NULL,
L"Star Chart",
NULL};
RegisterClassEx(&wc);
}
... rest of windows code ...
How can it be that this identical code works fine in one project and not in
the other?
Any ideas would be greatly appreciated because I have been at this for 6
hours now with no success...
If anybody needs to see any other code I would be glad to post it for you, I
really just don't know what to try now...
edit:
I have now found that it is the GetModuleHandle() call that is producing the
error? Can this be right?
Thanks in advance.
Mark Coleman
David Lowndes - 29 Nov 2004 16:21 GMT
>When I try to register my windows class using RegisterClassEx in my program
>I get an error which GetLastError tells me is error 120.
[quoted text clipped - 7 lines]
>built using UNICODE. Could this affect the outcome of function calls with
>identical input?
Yes, which OS are you testing on? Win9x OS's are unlikely to have an
implementation for the wide character version of the function.
Dave

Signature
MVP VC++ FAQ: http://www.mvps.org/vcfaq
mrmrcoleman - 29 Nov 2004 16:41 GMT
Oh David... 22 hours I have been on this little bastard... Incorrect field
entries I thought, a problem somewhere else in the code I thought! ;)
Thank you very much, you have made me a happy happy man.
Mark Coleman
> >When I try to register my windows class using RegisterClassEx in my program
> >I get an error which GetLastError tells me is error 120.
[quoted text clipped - 12 lines]
>
> Dave
David Lowndes - 29 Nov 2004 17:50 GMT
>Oh David... 22 hours I have been on this little bastard... Incorrect field
>entries I thought, a problem somewhere else in the code I thought! ;)
>
>Thank you very much, you have made me a happy happy man.
So you are testing on Win9x?
Note that you can use the Unicode version if you use MSLU:
"Windows 95/98/Me: RegisterClassExW is supported by the Microsoft®
Layer for Unicode (MSLU).
"
Dave

Signature
MVP VC++ FAQ: http://www.mvps.org/vcfaq