This shouldn't happen

Mehrdad wfunction at hotmail.com
Wed Apr 25 11:37:15 PDT 2012


There's an access violation when you run this. See if you can figure out the
error.

Guess what the cause is?
HINT: It would've been a 2-second fix instead of a 300-second fix, if D
hadn't been so shortsighted and hadn't removed typedef's...

import win32.windows;
void main() {
    auto hwnd = CreateWindow("STATIC", "Hi!", WS_OVERLAPPEDWINDOW |
WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
null, null, null, null);
    BOOL bRet;
    MSG msg;
    while ((bRet = GetMessage(null, &msg, 0, 0)) != 0) {
        if (bRet == -1) { break; }
        else {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }
} 



More information about the Digitalmars-d mailing list