/**
  * Get the current state of a window.
  *
  * @param hWnd native window handle
  * @return window state
  */
 private WindowState getWindowState(HWND hWnd) {
   WindowState windowState = new WindowState();
   windowState.setMaximized(ExtendedUser32.INSTANCE.IsZoomed(hWnd));
   if (windowState.getMaximized()) {
     ExtendedUser32.INSTANCE.SendMessage(
         hWnd, User32.WM_SYSCOMMAND, new WPARAM(ExtendedUser32.SC_RESTORE), new LPARAM(0));
   }
   windowState.setStyle(ExtendedUser32.INSTANCE.GetWindowLong(hWnd, ExtendedUser32.GWL_STYLE));
   windowState.setExStyle(ExtendedUser32.INSTANCE.GetWindowLong(hWnd, ExtendedUser32.GWL_EXSTYLE));
   RECT rect = new RECT();
   boolean gotWindowRect = ExtendedUser32.INSTANCE.GetWindowRect(hWnd, rect);
   if (gotWindowRect) {
     windowState.setLeft(rect.left);
     windowState.setTop(rect.top);
     windowState.setRight(rect.right);
     windowState.setBottom(rect.bottom);
   }
   return windowState;
 }