Sign in to follow this  
Followers 0
xFreakYx

hide IE Object border

3 posts in this topic

Hello,

does anyone how to hide the border of an IE object in a child gui?

This is my code:

#RequireAdmin
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <SendMessage.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <Array.au3>

_GDIPlus_Startup()
$oPage = _IECreateEmbedded()


$hGUI = GUICreate("hans", 450, 610, (@DesktopWidth / 2) - 400, -1, $WS_POPUP, $WS_EX_LAYERED); + $WS_EX_TOPMOST)
$hGUI_child = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_MDICHILD, $hGUI)
$hImage = _GDIPlus_ImageLoadFromFile("bg.png")
SetBitmap($hGUI, $hImage, 0xFF)
GUISetBkColor(0, $hGUI_child)
GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN")
GUISetState(@SW_SHOW, $hGUI)
GUISetState(@SW_SHOW, $hGUI_child)
_WinAPI_SetLayeredWindowAttributes($hGUI_child, 0x00, 0xff)

$hIE = _GUICtrlCreateIEObject(Default, $oPage, 500, 400, 0, 0, "http://fc09.deviantart.net/fs71/f/2011/323/3/8/autoit_icon_by_cacgolf-d4go7hg.png", 0)
;~ ControlMove (Default, "", $hIE, 100,0, 10, 10)
;~ WinMove ($hIE, "", 100, 0, 10, 10, 0)

While 1
    _Funktion()
WEnd

Func _Funktion()
    $msg = GUIGetMsg()
    Switch $msg
        Case -3
            Exit

    EndSwitch

EndFunc   ;==>_Funktion

Func SetBitmap($hGUI, $hImage, $iOpacity = 255)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
    $hScrDC = _WinAPI_GetDC(0)
    $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", 1)
    _WinAPI_UpdateLayeredWindow($hGUI, $hGUI, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)
EndFunc   ;==>SetBitmap

Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    _SendMessage($hGUI, $WM_SYSCOMMAND, 0xF012, 0)
EndFunc   ;==>_WM_LBUTTONDOWN


Func _GUICtrlCreateIEObject($iGui, $iObject, $iWidth, $iHeight, $iLeft, $iTop, $iUrl = "", $iWait = 1)
    $iIEGui = GUICreate("IE_" & Random(1, 100, 1), 10, 0, $iLeft, $iTop, $WS_CHILD, Default, $iGui)
    $GUIActiveX = GUICtrlCreateObj($iObject, -2, -2, $iWidth, $iHeight)
;~  GUICtrlSetResizing($GUIActiveX, $GUI_DOCKAUTO)
    _IENavigate($iObject, $iUrl, $iWait)
    $iObject.document.body.scroll = "no"
    $iObject.document.body.style.overflow = "hidden"
    GUISetState(@SW_SHOW, $iIEGui)
    Return SetError(0, $iIEGui, $GUIActiveX)
EndFunc   ;==>_GUICtrlCreateIEObject

post-54780-0-87038700-1425820598_thumb.p

post-54780-0-44061900-1425820605.jpg

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

 

Hello,

does anyone how to hide the border of an IE object in a child gui?

This is my code:

$hIE = _GUICtrlCreateIEObject(Default, $oPage, 500, 400, 0, 0, "http://fc09.deviantart.net/fs71/f/2011/323/3/8/autoit_icon_by_cacgolf-d4go7hg.png", 0)

 

Do you mean something like this?  Replace above line with below

$html = '<style> body { border: 0px;overflow:hidden;}</style></head><body><img src="http://fc09.deviantart.net/fs71/f/2011/323/3/8/autoit_icon_by_cacgolf-d4go7hg.png"></img></body></html>'

FileDelete(@TempDir & '\example_temp_html.html')
FileWrite(@TempDir & '\example_temp_html.html', $html)

$hIE = _GUICtrlCreateIEObject(Default, $oPage, 500, 400, 0, 0, @TempDir & '\example_temp_html.html', 0)

From the idea above you can see that if body style is set yo border: 0px we can hide the border. Also if we set overflow to hidden we can hide scrollbars (if needed).

If you are planning on opening websites in that window as opposed to local files you may need to intercept the html code and add/change the style of the page before creating the object.

Edited by mpower

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Okay so above way I provided was pretty crude so I revised it to a better method:

#RequireAdmin
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <SendMessage.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <Array.au3>

_GDIPlus_Startup()

$hGUI = GUICreate("hans", 450, 610, (@DesktopWidth / 2) - 400, -1, $WS_POPUP, $WS_EX_LAYERED); + $WS_EX_TOPMOST)
$hGUI_child = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_MDICHILD, $hGUI)
$hImage = _GDIPlus_ImageLoadFromFile(@DesktopDir& '\bg.png')
SetBitmap($hGUI, $hImage, 0xFF)
GUISetBkColor(0, $hGUI_child)
GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN")
GUISetState(@SW_SHOW, $hGUI)
GUISetState(@SW_SHOW, $hGUI_child)
_WinAPI_SetLayeredWindowAttributes($hGUI_child, 0x00, 0xff)

$oIE = _IECreateEmbedded()
$oIEEvents = ObjEvent($oIE, "_IEEvent_", "DWebBrowserEvents2")
$oIEobj = GUICtrlCreateObj($oIE, 0, 0,500, 400)
_IENavigate($oIE, "http://fc09.deviantart.net/fs71/f/2011/323/3/8/autoit_icon_by_cacgolf-d4go7hg.png")

Sleep(5000)

_IENavigate($oIE, "http://www.google.com")

Sleep(5000)

_IENavigate($oIE, "http://fc09.deviantart.net/fs71/f/2011/323/3/8/autoit_icon_by_cacgolf-d4go7hg.png")


While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case -3
            Exit
    EndSwitch
WEnd

Func _IEEvent_BeforeNavigate2()
    If $oIE <> '' Then
        _IELoadWait($oIE)
        $oIE.document.body.scroll = "no"
        $oIE.document.body.style.border = "0"
    EndIf
EndFunc   ;==>_IEEvent_BeforeNavigate2


Func SetBitmap($hGUI, $hImage, $iOpacity = 255)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
    $hScrDC = _WinAPI_GetDC(0)
    $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", 1)
    _WinAPI_UpdateLayeredWindow($hGUI, $hGUI, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)
EndFunc   ;==>SetBitmap

Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    _SendMessage($hGUI, $WM_SYSCOMMAND, 0xF012, 0)
EndFunc   ;==>_WM_LBUTTONDOWN

As you can see with this method even changing pages doesn't add the border/scrollbars. 

Edited by mpower

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0