@@ -557,11 +557,10 @@ static void CaptureRegionInit(void)
557
557
InvalidateRect (gWindow , NULL , FALSE);
558
558
}
559
559
560
- static void CaptureRegionDone (void )
560
+ static void CaptureRegionRelease (void )
561
561
{
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 );
565
564
566
565
if (gRectContext )
567
566
{
@@ -579,6 +578,14 @@ static void CaptureRegionDone(void)
579
578
}
580
579
}
581
580
581
+ static void CaptureRegionDone (void )
582
+ {
583
+ SetCursor (gCursorArrow );
584
+ ReleaseCapture ();
585
+
586
+ CaptureRegionRelease ();
587
+ }
588
+
582
589
static void CaptureRegion (void )
583
590
{
584
591
CaptureRegionDone ();
@@ -598,26 +605,35 @@ static void CaptureRegion(void)
598
605
SetWindowLongW (gWindow , GWL_EXSTYLE , ExStyle );
599
606
SetLayeredWindowAttributes (gWindow , RGB (255 , 0 , 255 ), 0 , LWA_COLORKEY );
600
607
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
-
608
608
ID3D11Device * Device = CreateDevice ();
609
609
if (!Device )
610
610
{
611
+ CaptureRegionRelease ();
611
612
return ;
612
613
}
613
614
614
615
if (!ScreenCapture_CreateForMonitor (& gCapture , Device , gRectMonitor , & Rect ))
615
616
{
616
617
ShowNotification (L"Cannot record monitor!" , L"Error" , NIIF_WARNING );
618
+ CaptureRegionRelease ();
617
619
return ;
618
620
}
619
621
620
622
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
+ }
621
637
}
622
638
623
639
static int GetPointResize (int X , int Y )
0 commit comments