Jump to content
Sign in to follow this  
user52

IE Embedded and "Embedded" Refresh

Recommended Posts

user52

Hello, I've used lod3n's method of embedding an IE window (seen here http://www.autoitscript.com/forum/index.php?showtopic=32804).

When I put, for example, a notepad window in front of the embedded window and move it, gray covers the embedded ie window.

embedded successfully created:

post-14453-1167765016_thumb.jpg

notepad window opened on top of embedded window and moved around

post-14453-1167765035_thumb.jpg

#include <GuiConstants.au3>
#include <IET2.0.6.au3>

$realtitle = 'MyGui'
$waittitle = "loading..."
$gui = GUICreate($waittitle, 800, 600, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

;label is reference for ie window
$label=GUICtrlCreateLabel("", 10, 10, 700, 500)
    GUICtrlSetResizing(-1,$GUI_DOCKAUTO)
    GUICtrlSetState(-1,$GUI_DISABLE)

_IEErrorHandlerRegister()

;set up the first IE window
$oIE1 = _IECreate("about:blank",0,0)
$oIE1.AddressBar = 0
$oIE1.MenuBar = 0
$oIE1.StatusBar = 1
$oIE1.ToolBar = 0
$uID1 = Random(1000, 100000000)
$oIE1.document.title = $uID1
WinWait($uID1)
$hoIE1 = WinGetHandle($uID1)
DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hoIE1, "int", -16, "long",$WS_POPUP)
DllCall("user32.dll", "int", "SetParent", "hwnd", $hoIE1, "hwnd", $gui)   

; show the gui and the IE windows
WinsetTitle($gui,"",$realtitle)
WinActivate($gui)
_IENavigate($oIE1, "http://www.google.com/", 0)
$oIE1.visible=1

RepositionIE()

GUISetState()
While 1
    $msg = GuiGetMsg()  
    Select
    Case $msg = $GUI_EVENT_CLOSE
        _Exit()
    Case Else
        ;this is the only way i've found that 'refreshes' the window to clear the gray
        While NOT WinActive($gui)
            RepositionRefresh()
            Sleep(500)
        WEnd
    EndSelect
WEnd

_Exit()

Func RepositionIE()
    $pos1 = ControlGetPos($gui, "", $label)
    If IsArray($pos1) Then
        WinMove($hoIE1, "", $pos1[0], $pos1[1], $pos1[2], $pos1[3])
    EndIf
EndFunc
Func RepositionRefresh()
    $pos1 = ControlGetPos($gui, "", $label)
    If IsArray($pos1) Then
        WinMove($hoIE1, "", $pos1[0], $pos1[1], $pos1[2], $pos1[3]+1) ;notice the + 1 here
        WinMove($hoIE1, "", $pos1[0], $pos1[1], $pos1[2], $pos1[3])
    EndIf
EndFunc
Func _Exit()
    $oIE1.Quit()
    GUIDelete($gui)
    Exit
EndFunc

Share this post


Link to post
Share on other sites
Ophidian

I am by no means an expert on this and quite possibly wrong but normally this happens in other programming languages when the window doesn't repaint itself. I don't know the GUI functions very well but if there is something to repaint/refresh/redraw the window then that will probably fix it.

Steppin out on a limb hopin it won't break.

Ophidian

Share this post


Link to post
Share on other sites
Kohr

Auto3Lib has a command to refresh what is drawn on the gui. You can also use the "AutoIt Craps" link in my sig to see an example of the same function made by PaulIa.

The command from his library is "_InvalidateRect" located in "A3LWinAPI.au3".

Kohr

Edited by Kohr

Share this post


Link to post
Share on other sites
user52

thanks for finding that :P

not sure how to say this, but it doesn't exactly refresh 'quietly' while not focused

here is what i have:

#include <GuiConstants.au3>
#include <IET2.0.6.au3>
#include <A3LWinAPI.au3>

$realtitle = 'MyGui'
$waittitle = "loading..."
$gui = GUICreate($waittitle, 800, 600, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

;label is reference for ie window
$label=GUICtrlCreateLabel("", 10, 10, 700, 500)
    GUICtrlSetResizing(-1,$GUI_DOCKAUTO)
    GUICtrlSetState(-1,$GUI_DISABLE)

_IEErrorHandlerRegister()

;set up the first IE window
$oIE1 = _IECreate("about:blank",0,0)
$oIE1.AddressBar = 0
$oIE1.MenuBar = 0
$oIE1.StatusBar = 1
$oIE1.ToolBar = 0
$uID1 = Random(1000, 100000000)
$oIE1.document.title = $uID1
WinWait($uID1)
$hoIE1 = WinGetHandle($uID1)
DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hoIE1, "int", -16, "long",$WS_POPUP)
DllCall("user32.dll", "int", "SetParent", "hwnd", $hoIE1, "hwnd", $gui)   

; show the gui and the IE windows
WinsetTitle($gui,"",$realtitle)
WinActivate($gui)
_IENavigate($oIE1, "http://www.google.com/", 0)
$oIE1.visible=1

RepositionIE()

GUISetState()
While 1
    $msg = GuiGetMsg()  
    Select
    Case $msg = $GUI_EVENT_CLOSE
        _Exit()
    Case Else
        ;this is the only way i've found that 'refreshes' the window to clear the gray
        While NOT WinActive($gui)
            If NOT WinActive($oIE1) Then
                ;RepositionRefresh()
                _API_InvalidateRect($oIE1)
                Sleep(500)
            EndIf
        WEnd
    EndSelect
WEnd

_Exit()

Func RepositionIE()
    $pos1 = ControlGetPos($gui, "", $label)
    If IsArray($pos1) Then
        WinMove($hoIE1, "", $pos1[0], $pos1[1], $pos1[2], $pos1[3])
    EndIf
EndFunc
Func RepositionRefresh()
    $pos1 = ControlGetPos($gui, "", $label)
    If IsArray($pos1) Then
        WinMove($hoIE1, "", $pos1[0], $pos1[1], $pos1[2], $pos1[3]+1) ;notice the + 1 here
        WinMove($hoIE1, "", $pos1[0], $pos1[1], $pos1[2], $pos1[3])
    EndIf
EndFunc
Func _Exit()
    _API_LocalFree($oIE1)
    $oIE1.Quit()
    GUIDelete($gui)
    Exit
EndFuncoÝ÷ ØIy×^w§v,çm¢·­ë!jËa{'hÖ®¶¶'¬¢g¡£Þ­íý±©ÞÅ©©æ®¶­sb6æ6ÇVFRfÇC´wV6öç7FçG2æS2fwC°¢6æ6ÇVFRfÇC´UC"ããbæS2fwC° ¢b33c¶wVÒuT7&VFRgV÷C´×wVgV÷C²ÂÂcÂÓÂÓÂ&Dõ"b33cµu5ôõdU$ÄTEtäDõrÂb33cµu5ô4Ä4$Ääu2 ¢b33c¶ôRÒôT7&VFTVÖ&VFFVB¢b33c´uT7FfUÒuT7G&Ä7&VFTö&¢b33c¶ôRÂÂÂsÂS¥ôTæfvFRb33c¶ôRÂgV÷C¶GG¢ò÷wwrævöövÆRæ6öÒgV÷C²Â ¤wV6WE7FFR¥vÆR b33c¶×6rÒwVvWD×6r 6VÆV7@ 66Rb33c¶×6rÒb33c´uTôUdTåEô4Äõ4P WDÆö÷ 66RVÇ6P ³° VæE6VÆV7@¥tVæ@¤W@

thanks for the help

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.