Here is the message loop:
```d
while(GetMessage(&msg, hwnd,0,0))   {
   if(msg.message == WM_QUIT)
      break;
   TranslateMessage(&msg);
   DispatchMessage(&msg);
}
```
The WndProc(LRESULT CALLBACK):
```d
extern(Windows)
LRESULT WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) nothrow {
        switch(msg)     {
                case WM_CREATE:
                        //...
                        return 0;
                        break;
                case WM_DESTROY:
                        try     {
                                entity.terminate();
                        }
                        catch(Throwable e)      {
                                PostQuitMessage(1);
                        }
                        PostQuitMessage(0);
                        break;
                default:
        }
return DefWindowProc(hwnd,msg,wparam,lparam);
}
```

When I run the program and close the window, the program still runs in background mode. I don't know why this happens nor how to fix it. Does anybody know what's going on?

Reply via email to