Skip to content

Commit af5b785

Browse files
committed
code review adoptions
1 parent a5383ce commit af5b785

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

src/modules/CropAndLock/CropAndLock/ScreenshotCropAndLockWindow.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ 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);
131132

132133
// Capture full window
@@ -138,8 +139,9 @@ void ScreenshotCropAndLockWindow::CropAndLock(HWND windowToCrop, RECT cropRect)
138139
int cropHeight = m_sourceRect.bottom - m_sourceRect.top;
139140

140141
HDC cropDC = CreateCompatibleDC(nullptr);
141-
HBITMAP cropBitmap = CreateCompatibleBitmap(GetDC(nullptr), cropWidth, cropHeight);
142+
HBITMAP cropBitmap = CreateCompatibleBitmap(screenDC, cropWidth, cropHeight);
142143
HGDIOBJ oldCropBitmap = SelectObject(cropDC, cropBitmap);
144+
ReleaseDC(nullptr, screenDC);
143145

144146
BitBlt(
145147
cropDC,
@@ -173,9 +175,4 @@ void ScreenshotCropAndLockWindow::CropAndLock(HWND windowToCrop, RECT cropRect)
173175
m_destRect = { 0, 0, cropWidth, cropHeight };
174176
m_captured = true;
175177
InvalidateRect(m_window, nullptr, FALSE);
176-
}
177-
178-
void ScreenshotCropAndLockWindow::Hide()
179-
{
180-
ShowWindow(m_window, SW_HIDE);
181178
}

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)