Win32 RegisterClass Error

GaboonViper gaboonviper at gmx.net
Sat Nov 17 04:43:34 PST 2007


Of course!

Thanks, this stupid problem had my brain whacked for hours:/ Sometimes  
it's the obvious that we can't figure out.

As for the messagepump thing. I'm not actually using the code I posted,  
except to figure out that one problem. I don't handle messages with a  
result <= 0. Though I don't actually raise an error message either, so I'm  
glad for this reminder.

Thanks again,
Boyd.

---------
On Sat, 17 Nov 2007 13:31:13 +0100, Lutger <lutger.blijdestijn at gmail.com>  
wrote:

> GaboonViper wrote:
>> Hi,
>>  I've been working with win32 libraries for a few weeks. I'm trying to  
>> build a GUI framework, as I'm not satisfied with the ones currently  
>> available.
>>  So currently I'm working on detecting win32 errors and I've found that  
>> RegisterClass is giving me an Error Code 2, which apparently translates  
>> to "The system cannot find the file specified".
>>  It doesn't really seem to matter what I change. It always gives me the  
>> same problem. I'm using the win32 headers from the bindings project on  
>> dsource.org. However I tried the std.c.windows.windows with the same  
>> results.
>>  Below is the code that reproduces the problem. It's basically a slice  
>> of one of the tutorials on dsource.org.
>>  Can anyone tell me what causes this error? And how to fix it?
>>  Boyd.
>
> The problem is that there is no problem. If you check the return value  
> of RegisterClass, you'll see that it works fine. The reason you get this  
> error from GetLastError, is because the last error is only defined when  
> an error actually occured. It doesn't tell you if a function executed  
> succesfully.
>
>
> A note about the message pump from msdn:
>
> <quote>
>
> Warning
>
> Because the return value can be nonzero, zero, or -1, avoid code like  
> this:
>
> while (GetMessage( lpMsg, hWnd, 0, 0)) ...
>
> The possibility of a -1 return value means that such code can lead to  
> fatal application errors. Instead, use code like this:
>
> BOOL bRet;
>
> while( (bRet = GetMessage( &msg, hWnd, 0, 0 )) != 0)
> {
>      if (bRet == -1)
>      {
>          // handle the error and possibly exit
>      }
>      else
>      {
>          TranslateMessage(&msg);
>          DispatchMessage(&msg);
>      }
> }
>
> </quote>


More information about the Digitalmars-d-learn mailing list