WinAPI – Determine if a window has maximize/restore capability

Problem: Determining if a window (by, say, hWnd) has the capability of being maximized or restored. Purpose of this is to programmatically send maximize/restore events to windows (for automation) but exclude windows which can’t handle it.

Please consider the following two example windows while trying to determine this from GetWindowLong with GWL_STYLE:


a) The Discord client app (it is built with Electron). It has styles:

  • WS_CAPTION
  • WS_SIZEBOX

It does NOT have styles:

  • WS_SYSMENU
  • WS_MAXIMIZE

This window does display a restore/maximize button and behaves properly when SW_MAXIMIZE/SW_RESTORE are posted to it.


b) The “Are you sure you want to quit?” prompt in InteliJ IDEA. It has styles:

  • WS_CAPTION
  • WS_SIZEBOX
  • WS_SYSMENU

It does NOT have style:

  • WS_MAXIMIZE

This window does NOT display a restore/maximize button and does NOT behave properly when SW_MAXIMIZE/SW_RESTORE are posted to it (it crashes the whole IDE).


So, given these two examples, the following facts are true:

1) A window with WS_SIZEBOX style does not guarantee that it can respond to WS_MAXIMIZE/WS_RESTORE messages safely;

2) A window without WS_SYSMENU nor WS_MAXIMIZE may still handle WS_MAXIMIZE/WS_RESTORE messages properly

3) Both of them have a native system menu that opens via title bar secondary-click and they correctly list maximize/restore as enabled or disabled (whatever matches their capability).

Given those two facts, how do I actually determine if a window can or cannot handle being maximized/restored? It seems it is not possible from window style alone, but I can’t find anything in the Win32 API WinAPI to do this.

Note that I am deciding on whether to send WS_MAXIMIZE/WS_RESTORE by calling GetWindowPlacement and checking the showCmd.

Also note that I am using Java/JNA but I understand C++ or C# perfectly fine if you want to share code snippets.