Pointers, casting, SetGetWindowLong problem...

Derek Parnell derek at psych.ward
Fri Mar 9 15:29:06 PST 2007


On Fri, 9 Mar 2007 23:16:34 -0000, Chris Warwick wrote:


>     TWindow window = cast(TWindow) cast(void*)  GetWindowLongA(handle, 0);
>     if (window == null)  return DefWindowProcA(handle, msg, wparam, lparam);
> 
> but i keep getting an access violation on the if (window == null),
> 
> if i change it to
> 
>     if (window == null) beep(400,50)
> 
> i still get it, the AV that is, but if i just skip the check and call the
> DefWindoProcA it works fine.

Use this instead ...

    if (window is null) ...

Because ...

    if (window == null)

is identical to 

    if (window.opEquals(null))

which will fail if 'window' is null because it needs to use it to reference
the opEquals method.


-- 
Derek Parnell
Melbourne, Australia
"Justice for David Hicks!"
skype: derek.j.parnell


More information about the Digitalmars-d-learn mailing list