Pointers, casting, SetGetWindowLong problem...

Chris Warwick sp at m.me.not
Fri Mar 9 15:16:34 PST 2007

Hi, i use this to create and show my window

            HINSTANCE hinstance = GetModuleHandleA(null);
            fhandle = CreateWindowExA(
                WS_EX_APPWINDOW, "CjWindow", "Testing 123", WS_TILEDWINDOW,
                x, y, width, height, HWND_DESKTOP, cast(HMENU) null,
                hinstance, null);
            SetWindowLongA(fhandle, 0, cast(LONG) cast(VOID*) this);
            ShowWindow(fhandle, SW_SHOW);

And this in my WindowProc

    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.

I cant work out why, even if i have fecked up the casting or setting of the
the windowLong var, testing what was returned against null shouldnt cause an
AV should it?

Anycase, any ideas what I've done wrong?



More information about the Digitalmars-d-learn mailing list