1 /*
2  * PROJECT:    PAINT for ReactOS
3  * LICENSE:    LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later)
4  * PURPOSE:    Window for fullscreen view
5  * COPYRIGHT:  Copyright 2015 Benedikt Freisen <b.freisen@gmx.net>
6  */
7 
8 #include "precomp.h"
9 
10 CFullscreenWindow fullscreenWindow;
11 
12 /* FUNCTIONS ********************************************************/
13 
14 HWND CFullscreenWindow::DoCreate()
15 {
16     if (m_hWnd)
17         return m_hWnd;
18 
19     RECT rc = {0, 0, 0, 0}; // Rely on SW_SHOWMAXIMIZED
20     return Create(HWND_DESKTOP, rc, NULL, WS_POPUPWINDOW, WS_EX_TOPMOST);
21 }
22 
23 LRESULT CFullscreenWindow::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
24 {
25     SendMessage(WM_SETICON, ICON_BIG, (LPARAM) LoadIcon(g_hinstExe, MAKEINTRESOURCE(IDI_APPICON)));
26     SendMessage(WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon(g_hinstExe, MAKEINTRESOURCE(IDI_APPICON)));
27     return 0;
28 }
29 
30 LRESULT CFullscreenWindow::OnCloseOrKeyDownOrLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
31 {
32     mainWindow.ShowWindow(SW_SHOW);
33     ShowWindow(SW_HIDE);
34     return 0;
35 }
36 
37 LRESULT CFullscreenWindow::OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
38 {
39     PAINTSTRUCT ps;
40     HDC hDC = BeginPaint(&ps);
41     RECT rcWnd;
42     GetWindowRect(&rcWnd);
43     INT cxDest = imageModel.GetWidth();
44     INT cyDest = imageModel.GetHeight();
45     INT xDest = (rcWnd.right - rcWnd.left - cxDest) / 2;
46     INT yDest = (rcWnd.bottom - rcWnd.top - cyDest) / 2;
47     BitBlt(hDC, xDest, yDest, cxDest, cyDest, imageModel.GetDC(), 0, 0, SRCCOPY);
48     EndPaint(&ps);
49     return 0;
50 }
51 
52 LRESULT CFullscreenWindow::OnGetText(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
53 {
54     // return caption of the main window, instead
55     return mainWindow.SendMessage(nMsg, wParam, lParam);
56 }
57