@@ -126,8 +126,10 @@ void ScreenshotCropAndLockWindow::CropAndLock(HWND windowToCrop, RECT cropRect)
126
126
int fullHeight = windowRect.bottom - windowRect.top ;
127
127
128
128
HDC fullDC = CreateCompatibleDC (nullptr );
129
- HBITMAP fullBitmap = CreateCompatibleBitmap (GetDC (nullptr ), fullWidth, fullHeight);
129
+ HDC screenDC = GetDC (nullptr );
130
+ HBITMAP fullBitmap = CreateCompatibleBitmap (screenDC, fullWidth, fullHeight);
130
131
HGDIOBJ oldFullBitmap = SelectObject (fullDC, fullBitmap);
132
+ ReleaseDC (nullptr , screenDC);
131
133
132
134
// Capture full window
133
135
winrt::check_bool (PrintWindow (windowToCrop, fullDC, PW_RENDERFULLCONTENT));
@@ -138,8 +140,10 @@ void ScreenshotCropAndLockWindow::CropAndLock(HWND windowToCrop, RECT cropRect)
138
140
int cropHeight = m_sourceRect.bottom - m_sourceRect.top ;
139
141
140
142
HDC cropDC = CreateCompatibleDC (nullptr );
141
- HBITMAP cropBitmap = CreateCompatibleBitmap (GetDC (nullptr ), cropWidth, cropHeight);
143
+ HDC screenDC2 = GetDC (nullptr );
144
+ HBITMAP cropBitmap = CreateCompatibleBitmap (screenDC2, cropWidth, cropHeight);
142
145
HGDIOBJ oldCropBitmap = SelectObject (cropDC, cropBitmap);
146
+ ReleaseDC (nullptr , screenDC2);
143
147
144
148
BitBlt (
145
149
cropDC,
@@ -173,9 +177,4 @@ void ScreenshotCropAndLockWindow::CropAndLock(HWND windowToCrop, RECT cropRect)
173
177
m_destRect = { 0 , 0 , cropWidth, cropHeight };
174
178
m_captured = true ;
175
179
InvalidateRect (m_window, nullptr , FALSE );
176
- }
177
-
178
- void ScreenshotCropAndLockWindow::Hide ()
179
- {
180
- ShowWindow (m_window, SW_HIDE);
181
180
}
0 commit comments