Spiff59 Posted June 25, 2010 Share Posted June 25, 2010 (edited) I borrowed the following code (pretty much) from a 2006 thread: expandcollapse popup#include <IE.au3> #include <GUIConstants.au3> #include <WindowsConstants.au3> _IEErrorHandlerRegister () $oIE = _IECreateEmbedded() GUICreate("Embedded word control Test", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _ $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 620, 360) GUISetState() $sFile = @DesktopDir & "\Aetrex.Doc" _IENavigate ($oIE, $sFile, 0) While $oIE.ReadyState <> 4 Sleep(50) WEnd $oDoc = $oIE.Document $oWord = $oDoc.Application ; Put document into 'Web View' mode $oWord.Activewindow.View = 6 ; Manage display of toolbars $oDoc.CommandBars ("Reviewing").Visible = False $oDoc.CommandBars ("Standard").Visible = False ; $oDoc.CommandBars("Formatting").Visible = False ; $oDoc.CommandBars("Drawing").Visible = False ; $oDoc.CommandBars("Forms").Visible = False ; $oDoc.DisplayStatusBar = False ; $oDoc.DisplayCommentIndicator = 0 While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch Sleep(50) WEnd _IENavigate ($oIE, "about:blank") $oDoc = 0 $oWord = 0 GUIDelete() Exit It parks a Word document inside an IE object in your GUI. If you minimize and restore the window, nothing gets repainted. Is there a fix for this one? PS - I was also looking for a way to disable the "view" toolbar in the bottom left... Edited June 25, 2010 by Spiff59 Link to comment Share on other sites More sharing options...
Spiff59 Posted June 26, 2010 Author Share Posted June 26, 2010 (edited) Toggling the screwy $WS_EX_COMPOSITED style seems to give me a better than 90% success rate in repainting the Word portion of the GUI after a minimize/losefocus event. So, this is the cheesy work-around I have now: expandcollapse popup#include <IE.au3> #include <GUIConstants.au3> #include <WindowsConstants.au3> Global Const $SC_RESTORE = 0xF120; Global $Redraw_flag _IEErrorHandlerRegister () $oIE = _IECreateEmbedded() $hGUI = GUICreate("Embedded word control Test", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _ $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 620, 360) $button = GUICtrlCreateButton("Minimize, then Restore", 210, 480, 200, 20) GUISetState() $sFile = @DesktopDir & "\test.Doc" _IENavigate ($oIE, $sFile, 0) While $oIE.ReadyState <> 4 Sleep(50) WEnd $oDoc = $oIE.Document $oWord = $oDoc.Application ; Put document into 'Web View' mode $oWord.Activewindow.View = 6 ; Manage display of toolbars $oDoc.CommandBars ("Reviewing").Visible = False $oDoc.CommandBars ("Standard").Visible = False ; $oDoc.CommandBars("Formatting").Visible = False ; $oDoc.CommandBars("Drawing").Visible = False ; $oDoc.CommandBars("Forms").Visible = False ; $oDoc.DisplayStatusBar = False ; $oDoc.DisplayCommentIndicator = 0 GUIRegisterMsg($WM_ACTIVATE,"WM_ACTIVATE") While 1 $msg = GUIGetMsg() Switch $msg Case $button GUISetState(@SW_MINIMIZE) Sleep(300) GUISetState(@SW_RESTORE) Case $GUI_EVENT_CLOSE ExitLoop EndSwitch If $Redraw_flag Then GUISetStyle(-1, $WS_EX_COMPOSITED, $hGUI) ; Sleep(50) GUISetStyle(-1, 0, $hGUI) $Redraw_flag = 0 EndIf Sleep(50) WEnd _IENavigate ($oIE, "about:blank") $oDoc = 0 $oWord = 0 GUIDelete() Exit Func WM_ACTIVATE($hWndGUI, $MsgID, $wParam, $lParam) If $wParam = 1 Then $Redraw_flag = 1 EndIf Return $GUI_RUNDEFMSG EndFunc Still no other ideas? PS - You need to point the script ($sFile) to some sort of Word doc to run it. Edited June 26, 2010 by Spiff59 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now