Skip to content

Commit f6eb319

Browse files
authored
Merge pull request #104 from mlipok/patch-1
Update NetWebView2Lib.au3 - _NetWebView2_NavigateToPDF() : __NetWebView2_freezer() refactoring
2 parents 33a8d90 + a1f5a28 commit f6eb319

1 file changed

Lines changed: 20 additions & 26 deletions

File tree

NetWebView2Lib.au3

Lines changed: 20 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,31 @@ 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+
1423+
Local Const $PW_RENDERFULLCONTENT = 0x2 ; this will go to where it should =)
1424+
_WinAPI_PrintWindow($hWindow_WebView2, $hDestination_DC, $PW_RENDERFULLCONTENT) ; print window to destination Window DC ; https://www.autoitscript.com/forum/topic/153782-help-filedocumentation-issues-discussion-only/page/40/#findComment-1549380
1425+
1426+
_WinAPI_ReleaseDC($hPic, $hPictureDC)
1427+
_WinAPI_SelectObject($hDestination_DC, $hDestination_Sv)
1428+
_WinAPI_DeleteDC($hDestination_DC)
14351429

14361430
; 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
1431+
_SendMessage($hPic, $STM_SETIMAGE, 0, $hDestination_Bitmap)
1432+
_WinAPI_DeleteObject($hDestination_Bitmap)
14421433

1443-
_SendMessage($hWindow_WebView2, $WM_SETREDRAW, False, 0) ; Disables ; https://www.autoitscript.com/forum/topic/199172-disable-gui-updating-repainting/
1434+
WinSetState($hWindow_WebView2, '', @SW_HIDE)
14441435
Return $idPic
14451436
#EndRegion ; freeze $hWindow_WebView2
14461437
EndFunc ;==>__NetWebView2_freezer
@@ -2186,3 +2177,6 @@ EndFunc ;==>__NetWebView2_Events__OnScreenCaptureStarting
21862177
#EndRegion ; NetWebView2Lib UDF - === EVENT HANDLERS === #TODO
21872178

21882179
#EndRegion ; NetWebView2Lib UDF - === EVENT HANDLERS ===
2180+
2181+
2182+

0 commit comments

Comments
 (0)