Skip to content

Commit a1470bb

Browse files
authored
Update NetWebView2Lib.au3
1 parent 9ca53f4 commit a1470bb

1 file changed

Lines changed: 16 additions & 26 deletions

File tree

NetWebView2Lib.au3

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,8 +1395,7 @@ Func __NetWebView2_freezer($oWebV2M, ByRef $idPic)
13951395
Local $hWindow_WebView2 = WinGetHandle($oWebV2M.BrowserWindowHandle)
13961396
#Region ; if $idPic is given then it means you already have it and want to delete it - unfreeze - show WebView2 content
13971397
If $idPic Then
1398-
_SendMessage($hWindow_WebView2, $WM_SETREDRAW, True, 0) ; Enables
1399-
_WinAPI_RedrawWindow($hWindow_WebView2, 0, 0, BitOR($RDW_FRAME, $RDW_INVALIDATE, $RDW_ALLCHILDREN)) ; Repaints
1398+
WinSetState($hWindow_WebView2, '', @SW_SHOW)
14001399
GUICtrlDelete($idPic)
14011400
$idPic = 0
14021401
Return
@@ -1408,39 +1407,29 @@ Func __NetWebView2_freezer($oWebV2M, ByRef $idPic)
14081407
#Region ; add PIC to parent window
14091408
Local $hWindow_Parent = WinGetHandle($oWebV2M.ParentWindowHandle)
14101409
Local $aPos = WinGetPos($hWindow_WebView2)
1411-
;~ _ArrayDisplay($aPos, '$aPos ' & @ScriptLineNumber)
14121410
Local $hPrev = GUISwitch($hWindow_Parent)
14131411
$idPic = GUICtrlCreatePic('', 0, 0, $aPos[2], $aPos[3])
14141412
Local $hPic = GUICtrlGetHandle($idPic)
14151413
GUISwitch($hPrev)
14161414
#EndRegion ; add PIC to parent window
14171415

1418-
; Create bitmap
1419-
Local $hDC = _WinAPI_GetDC($hPic)
1420-
Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC)
1421-
Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $aPos[2], $aPos[3])
1422-
Local $hDestSv = _WinAPI_SelectObject($hDestDC, $hBitmap)
1423-
Local $hSrcDC = _WinAPI_CreateCompatibleDC($hDC)
1424-
Local $hBmp = _WinAPI_CreateCompatibleBitmap($hDC, $aPos[2], $aPos[3])
1425-
Local $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hBmp)
1426-
_WinAPI_PrintWindow($hWindow_WebView2, $hSrcDC, 2)
1427-
_WinAPI_BitBlt($hDestDC, 0, 0, $aPos[2], $aPos[3], $hSrcDC, 0, 0, $MERGECOPY)
1428-
1429-
_WinAPI_ReleaseDC($hPic, $hDC)
1430-
_WinAPI_SelectObject($hDestDC, $hDestSv)
1431-
_WinAPI_SelectObject($hSrcDC, $hSrcSv)
1432-
_WinAPI_DeleteDC($hDestDC)
1433-
_WinAPI_DeleteDC($hSrcDC)
1434-
_WinAPI_DeleteObject($hBmp)
1416+
Local $hPictureDC = _WinAPI_GetDC($hPic)
1417+
1418+
; Create Dest bitmap
1419+
Local $hDestination_DC = _WinAPI_CreateCompatibleDC($hPictureDC) ; Creates a memory device context compatible with the specified device
1420+
Local $hDestination_Bitmap = _WinAPI_CreateCompatibleBitmap($hPictureDC, $aPos[2], $aPos[3]) ; Creates a bitmap compatible with the specified device context
1421+
Local $hDestination_Sv = _WinAPI_SelectObject($hDestination_DC, $hDestination_Bitmap) ; Selects an object into the specified device context
1422+
_WinAPI_PrintWindow($hWindow_WebView2, $hDestination_DC, 2)
1423+
1424+
_WinAPI_ReleaseDC($hPic, $hPictureDC)
1425+
_WinAPI_SelectObject($hDestination_DC, $hDestination_Sv)
1426+
_WinAPI_DeleteDC($hDestination_DC)
14351427

14361428
; Set bitmap to control
1437-
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
1438-
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
1439-
If $hObj <> $hBitmap Then
1440-
_WinAPI_DeleteObject($hBitmap)
1441-
EndIf
1429+
_SendMessage($hPic, $STM_SETIMAGE, 0, $hDestination_Bitmap)
1430+
_WinAPI_DeleteObject($hDestination_Bitmap)
14421431

1443-
_SendMessage($hWindow_WebView2, $WM_SETREDRAW, False, 0) ; Disables ; https://www.autoitscript.com/forum/topic/199172-disable-gui-updating-repainting/
1432+
WinSetState($hWindow_WebView2, '', @SW_HIDE)
14441433
Return $idPic
14451434
#EndRegion ; freeze $hWindow_WebView2
14461435
EndFunc ;==>__NetWebView2_freezer
@@ -2187,3 +2176,4 @@ EndFunc ;==>__NetWebView2_Events__OnScreenCaptureStarting
21872176

21882177
#EndRegion ; NetWebView2Lib UDF - === EVENT HANDLERS ===
21892178

2179+

0 commit comments

Comments
 (0)