How do I return a boolean as a WinDef.LRESULT?

478 views Asked by At

I'm trying to implement the Windows Restart Manager on my Java program and I got to the point where I'm receiving the messages from Windows and executing a callback that looks like this:

WindowProc proc = (hwnd, msg, wp, lp) -> {
    if (msg == WM_QUERYENDSESSION && lp.intValue() == ENDSESSION_CLOSEAPP) {
        // Here I need to return true to signify that the application is ready to quit.
     }
     // Pass the message to the default window procedure
     return user32.DefWindowProc(hwnd, msg, wp, lp);
};

where WindowProc looks like this:

private interface WindowProc extends StdCallLibrary.StdCallCallback {
    WinDef.LRESULT callback(WinDef.HWND hwnd, int msg, WinDef.WPARAM wp, WinDef.LPARAM lp);
}

According to the Restart Manager guidelines for Applications:

The Restart Manager queries GUI applications for shutdown by sending a WM_QUERYENDSESSION notification that has the lParam parameter set to ENDSESSION_CLOSEAPP (0x1). [...] GUI applications should listen for the WM_QUERYENDSESSION message and return a value of TRUE if the application is prepared to shut down and restart. [...]

How do I actually return true when the return value is a WinDef.LRESULT? I take it it's a pointer and somehow I need to construct a Win32 boolean and return a pointer to it?

0

There are 0 answers