Skip to content

Commit edefaeb

Browse files
committed
fix border still showing when cannot start region capture
fixes #36
1 parent c31fd78 commit edefaeb

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

wcap.c

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -557,11 +557,10 @@ static void CaptureRegionInit(void)
557557
InvalidateRect(gWindow, NULL, FALSE);
558558
}
559559

560-
static void CaptureRegionDone(void)
560+
static void CaptureRegionRelease(void)
561561
{
562-
ShowWindow(gWindow, SW_HIDE);
563-
SetCursor(gCursorArrow);
564-
ReleaseCapture();
562+
SetWindowPos(gWindow, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_HIDEWINDOW | SWP_NOMOVE | SWP_NOSIZE);
563+
SetWindowLongW(gWindow, GWL_EXSTYLE, 0);
565564

566565
if (gRectContext)
567566
{
@@ -579,6 +578,14 @@ static void CaptureRegionDone(void)
579578
}
580579
}
581580

581+
static void CaptureRegionDone(void)
582+
{
583+
SetCursor(gCursorArrow);
584+
ReleaseCapture();
585+
586+
CaptureRegionRelease();
587+
}
588+
582589
static void CaptureRegion(void)
583590
{
584591
CaptureRegionDone();
@@ -598,26 +605,35 @@ static void CaptureRegion(void)
598605
SetWindowLongW(gWindow, GWL_EXSTYLE, ExStyle);
599606
SetLayeredWindowAttributes(gWindow, RGB(255, 0, 255), 0, LWA_COLORKEY);
600607

601-
int X = Info.rcMonitor.left + Rect.left - (WCAP_RECT_BORDER + 1);
602-
int Y = Info.rcMonitor.top + Rect.top - (WCAP_RECT_BORDER + 1);
603-
int W = Rect.right - Rect.left + 2 * (WCAP_RECT_BORDER + 1);
604-
int H = Rect.bottom - Rect.top + 2 * (WCAP_RECT_BORDER + 1);
605-
SetWindowPos(gWindow, HWND_TOPMOST, X, Y, W, H, SWP_SHOWWINDOW);
606-
InvalidateRect(gWindow, NULL, FALSE);
607-
608608
ID3D11Device* Device = CreateDevice();
609609
if (!Device)
610610
{
611+
CaptureRegionRelease();
611612
return;
612613
}
613614

614615
if (!ScreenCapture_CreateForMonitor(&gCapture, Device, gRectMonitor, &Rect))
615616
{
616617
ShowNotification(L"Cannot record monitor!", L"Error", NIIF_WARNING);
618+
CaptureRegionRelease();
617619
return;
618620
}
619621

620622
StartRecording(Device, NULL);
623+
624+
if (gRecording)
625+
{
626+
int X = Info.rcMonitor.left + Rect.left - (WCAP_RECT_BORDER + 1);
627+
int Y = Info.rcMonitor.top + Rect.top - (WCAP_RECT_BORDER + 1);
628+
int W = Rect.right - Rect.left + 2 * (WCAP_RECT_BORDER + 1);
629+
int H = Rect.bottom - Rect.top + 2 * (WCAP_RECT_BORDER + 1);
630+
SetWindowPos(gWindow, HWND_TOPMOST, X, Y, W, H, SWP_SHOWWINDOW);
631+
InvalidateRect(gWindow, NULL, FALSE);
632+
}
633+
else
634+
{
635+
CaptureRegionRelease();
636+
}
621637
}
622638

623639
static int GetPointResize(int X, int Y)

0 commit comments

Comments
 (0)