@@ -126,7 +126,8 @@ 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);
131
132
132
133
// Capture full window
@@ -138,8 +139,9 @@ void ScreenshotCropAndLockWindow::CropAndLock(HWND windowToCrop, RECT cropRect)
138
139
int cropHeight = m_sourceRect.bottom - m_sourceRect.top ;
139
140
140
141
HDC cropDC = CreateCompatibleDC (nullptr );
141
- HBITMAP cropBitmap = CreateCompatibleBitmap (GetDC ( nullptr ) , cropWidth, cropHeight);
142
+ HBITMAP cropBitmap = CreateCompatibleBitmap (screenDC , cropWidth, cropHeight);
142
143
HGDIOBJ oldCropBitmap = SelectObject (cropDC, cropBitmap);
144
+ ReleaseDC (nullptr , screenDC);
143
145
144
146
BitBlt (
145
147
cropDC,
@@ -173,9 +175,4 @@ void ScreenshotCropAndLockWindow::CropAndLock(HWND windowToCrop, RECT cropRect)
173
175
m_destRect = { 0 , 0 , cropWidth, cropHeight };
174
176
m_captured = true ;
175
177
InvalidateRect (m_window, nullptr , FALSE );
176
- }
177
-
178
- void ScreenshotCropAndLockWindow::Hide ()
179
- {
180
- ShowWindow (m_window, SW_HIDE);
181
178
}
0 commit comments