Skip to content

Commit 3e5ca9e

Browse files
committed
code review adoptions
1 parent a5383ce commit 3e5ca9e

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/modules/CropAndLock/CropAndLock/ScreenshotCropAndLockWindow.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,10 @@ void ScreenshotCropAndLockWindow::CropAndLock(HWND windowToCrop, RECT cropRect)
126126
int fullHeight = windowRect.bottom - windowRect.top;
127127

128128
HDC fullDC = CreateCompatibleDC(nullptr);
129-
HBITMAP fullBitmap = CreateCompatibleBitmap(GetDC(nullptr), fullWidth, fullHeight);
129+
HDC screenDC = GetDC(nullptr);
130+
HBITMAP fullBitmap = CreateCompatibleBitmap(screenDC, fullWidth, fullHeight);
130131
HGDIOBJ oldFullBitmap = SelectObject(fullDC, fullBitmap);
132+
ReleaseDC(nullptr, screenDC);
131133

132134
// Capture full window
133135
winrt::check_bool(PrintWindow(windowToCrop, fullDC, PW_RENDERFULLCONTENT));
@@ -138,8 +140,10 @@ void ScreenshotCropAndLockWindow::CropAndLock(HWND windowToCrop, RECT cropRect)
138140
int cropHeight = m_sourceRect.bottom - m_sourceRect.top;
139141

140142
HDC cropDC = CreateCompatibleDC(nullptr);
141-
HBITMAP cropBitmap = CreateCompatibleBitmap(GetDC(nullptr), cropWidth, cropHeight);
143+
HDC screenDC2 = GetDC(nullptr);
144+
HBITMAP cropBitmap = CreateCompatibleBitmap(screenDC2, cropWidth, cropHeight);
142145
HGDIOBJ oldCropBitmap = SelectObject(cropDC, cropBitmap);
146+
ReleaseDC(nullptr, screenDC2);
143147

144148
BitBlt(
145149
cropDC,
@@ -173,9 +177,4 @@ void ScreenshotCropAndLockWindow::CropAndLock(HWND windowToCrop, RECT cropRect)
173177
m_destRect = { 0, 0, cropWidth, cropHeight };
174178
m_captured = true;
175179
InvalidateRect(m_window, nullptr, FALSE);
176-
}
177-
178-
void ScreenshotCropAndLockWindow::Hide()
179-
{
180-
ShowWindow(m_window, SW_HIDE);
181180
}

src/modules/CropAndLock/CropAndLock/ScreenshotCropAndLockWindow.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ struct ScreenshotCropAndLockWindow : robmikh::common::desktop::DesktopWindow<Scr
1616
private:
1717
static void RegisterWindowClass();
1818

19-
void Hide();
20-
2119
private:
2220
std::unique_ptr<void, decltype(&DeleteObject)> m_bitmap{ nullptr, &DeleteObject };
2321
RECT m_destRect = {};

0 commit comments

Comments
 (0)