ReactOS 0.4.16-dev-122-g325d74c
miniature.cpp
Go to the documentation of this file.
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 procedure of the main window and all children apart from
5 * hPalWin, hToolSettings and hSelection
6 * COPYRIGHT: Copyright 2015 Benedikt Freisen <b.freisen@gmx.net>
7 * Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
8 */
9
10#include "precomp.h"
11
13
14/* FUNCTIONS ********************************************************/
15
16CMiniatureWindow::CMiniatureWindow()
17 : m_hbmCached(NULL)
18{
19}
20
22{
23 if (m_hbmCached)
25}
26
28{
29 if (m_hWnd)
30 return m_hWnd;
31
32 RECT rc =
33 {
37 };
38
39 WCHAR strTitle[100];
41
43 return Create(hwndParent, rc, strTitle, style, WS_EX_PALETTEWINDOW);
44}
45
47{
48 if (IsWindowVisible() && !IsIconic() && !IsZoomed())
49 {
50 CRect rc;
51 GetWindowRect(&rc);
54 }
55 return 0;
56}
57
59{
60 if (IsWindowVisible() && !IsIconic() && !IsZoomed())
61 {
62 CRect rc;
63 GetWindowRect(&rc);
66 }
67 return 0;
68}
69
71{
74 return 0;
75}
76
78{
79 return TRUE; /* Avoid flickering */
80}
81
83{
84 RECT rc;
85 GetClientRect(&rc);
86
87 // Start painting
88 PAINTSTRUCT ps;
89 HDC hDC = BeginPaint(&ps);
90 if (!hDC)
91 return 0;
92
93 // Use a memory bitmap to reduce flickering
97
98 // FIXME: Consider aspect ratio
99
100 // Fill the background
101 ::FillRect(hdcMem, &rc, (HBRUSH)(COLOR_BTNFACE + 1));
102
103 // Draw the image (hdcMem <-- imageModel)
104 int cxImage = imageModel.GetWidth();
105 int cyImage = imageModel.GetHeight();
106 ::StretchBlt(hdcMem, 0, 0, rc.right, rc.bottom,
107 imageModel.GetDC(), 0, 0, cxImage, cyImage,
108 SRCCOPY);
109
110 // Move the image (hDC <-- hdcMem)
111 ::BitBlt(hDC, 0, 0, rc.right, rc.bottom, hdcMem, 0, 0, SRCCOPY);
112
113 // Clean up
114 ::SelectObject(hdcMem, hbmOld);
116
117 EndPaint(&ps);
118 return 0;
119}
120
122{
123 // Avoid too small
125 pInfo->ptMinTrackSize = { 100, 75 };
126 return 0;
127}
static HDC hDC
Definition: 3dtext.c:33
Arabic default style
Definition: afstyles.h:94
HINSTANCE g_hinstExe
Definition: main.cpp:17
RegistrySettings registrySettings
Definition: registry.cpp:14
#define IDS_MINIATURETITLE
Definition: resource.h:193
@ Create
Definition: registry.c:563
LRESULT OnEraseBkgnd(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: miniature.cpp:77
LRESULT OnGetMinMaxInfo(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: miniature.cpp:121
virtual ~CMiniatureWindow()
Definition: miniature.cpp:21
LRESULT OnClose(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: miniature.cpp:70
HBITMAP m_hbmCached
Definition: miniature.h:32
LRESULT OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: miniature.cpp:82
HWND DoCreate(HWND hwndParent)
Definition: miniature.cpp:27
LRESULT OnMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: miniature.cpp:46
LRESULT OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: miniature.cpp:58
int Width() const noexcept
Definition: atltypes.h:461
int Height() const noexcept
Definition: atltypes.h:318
int GetWidth() const
Definition: history.cpp:253
int GetHeight() const
Definition: history.cpp:258
HDC GetDC()
Definition: history.cpp:271
DWORD ThumbXPos
Definition: registry.h:26
DWORD ThumbYPos
Definition: registry.h:27
DWORD ThumbWidth
Definition: registry.h:25
DWORD ShowThumbnail
Definition: registry.h:22
DWORD ThumbHeight
Definition: registry.h:24
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
static HWND hwndParent
Definition: cryptui.c:300
HBITMAP CachedBufferDIB(HBITMAP hbm, int minimalWidth, int minimalHeight)
Definition: dib.cpp:115
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:57
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
pKey DeleteObject()
ImageModel imageModel
Definition: history.cpp:11
CMiniatureWindow miniature
Definition: miniature.cpp:12
static HDC
Definition: imagelist.c:88
unsigned int UINT
Definition: ndis.h:50
#define WS_CAPTION
Definition: pedump.c:624
#define WS_OVERLAPPED
Definition: pedump.c:615
#define WS_SYSMENU
Definition: pedump.c:629
long LONG
Definition: pedump.c:60
#define WS_THICKFRAME
Definition: pedump.c:630
#define _countof(array)
Definition: sndvol32.h:70
POINT ptMinTrackSize
Definition: winuser.h:3633
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
HDC hdcMem
Definition: welcome.c:104
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
#define SRCCOPY
Definition: wingdi.h:333
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
BOOL WINAPI DeleteDC(_In_ HDC)
#define SW_HIDE
Definition: winuser.h:771
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
BOOL WINAPI IsIconic(_In_ HWND)
#define WS_EX_PALETTEWINDOW
Definition: winuser.h:399
BOOL WINAPI IsZoomed(_In_ HWND)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
struct tagMINMAXINFO * LPMINMAXINFO
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
BOOL WINAPI IsWindowVisible(_In_ HWND)
#define COLOR_BTNFACE
Definition: winuser.h:931
__wchar_t WCHAR
Definition: xmlstorage.h:180