Beispiel #1
0
LRESULT WINAPI wndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
  switch (msg)
  {
  case WM_CREATE:
    ::hWnd = hWnd;
    break;
  case WM_CLOSE:
    onClose();
    break;
  case WM_SIZE:
    {
      int newWidth = LOWORD(lParam);
      int newHeight = HIWORD(lParam);
      size.set(newWidth, newHeight);
      screenToNDC = Transform::screenToNDC<float>(size);
      if (widget != 0)
      {
        widget->setBounds(Box2i::minSize(Vector2i::zero(), size));
      }
    }
    break;
  case WM_SYSKEYDOWN:
  case WM_KEYDOWN:
    if (wParam == VK_RETURN && (lParam & 0xffff) == 1 && GetKeyState(VK_MENU) < 0) // alt-enter
    {
      Application::toggleFullScreen();
    }
    break;
  default:
    return DefWindowProc(hWnd, msg, wParam, lParam);
  }
  return 0;
}
Beispiel #2
0
void Application::toggleFullScreen ()
{
  if (fullscreen)
  {
#ifdef _WIN32
  SetWindowLongPtr(hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW | WS_VISIBLE);
  SetWindowPos(hWnd, NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE | SWP_FRAMECHANGED | SWP_SHOWWINDOW);
  // ShowWindow(hWnd, SW_SHOWNORMAL);
#endif
  }
  else
  {
#ifdef _WIN32
  SetWindowLongPtr(hWnd, GWL_STYLE, WS_POPUP | WS_VISIBLE);
  SetWindowPos(hWnd, NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE | SWP_FRAMECHANGED | SWP_SHOWWINDOW);
  // ShowWindow(hWnd, SW_SHOWMAXIMIZED);
#endif
  }
  fullscreen = !fullscreen;

  // Set the size.
#ifdef _WIN32
  RECT rect;
  GetClientRect(hWnd, &rect);
  size.set(rect.right, rect.bottom); // left and top are always 0.
#endif

  screenToNDC = Transform::screenToNDC<float>(size);
  if (widget != 0)
  {
    widget->setBounds(Box2i::minSize(Vector2i::zero(), size));
  }
}