Nahuel Posted November 23, 2007 Share Posted November 23, 2007 (edited) I'm trying to simulate a rich edit control using an embedded IE object in a GUI (Valuater's idea). It works really great, but the scrolling problem is really annoying...here's an example, type something and press enter.expandcollapse popup#include <GUIConstants.au3> #include <IE.au3> $XT_oIE = _IECreateEmbedded() $MainGui = GUICreate("Chat",624, 446) $Obj_RCV = GUICtrlCreateObj($XT_oIE, 6, 20, 600, 346) _IENavigate($XT_oIE, "about:blank") $EditSend = GUICtrlCreateEdit("",6, 374, 539, 61, $WS_VSCROLL) $Send = GUICtrlCreateButton("Send", 556, 382, 57, 53, $BS_DEFPUSHBUTTON) GUICtrlSetState($EditSend,$GUI_FOCUS) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Send XSkinText(GUICtrlRead($EditSend)) GUICtrlSetData($EditSend,"") GUICtrlSetState($EditSend,$GUI_FOCUS) EndSwitch WEnd Func XSkinText($msg = "", $color = "black", $size = "3") If $msg == "/clr" Then Return _IEDocWriteHTML($XT_oIE, "") If $msg == "/exit" Then Exit If StringInStr($msg,"/goto:",1) Then $URL=StringSplit($msg,":") Return _IENavigate($XT_oIE,StringStripWS($URL[2],8) ,0) EndIf ;Smilies $SmilieDir=@ScriptDir & "\caritas" $msg=StringReplace($msg,":)", '<img src="' & $SmilieDir & '\smile.gif">') $msg=StringReplace($msg,":D", '<img src="' & $SmilieDir & '\smile.gif">') $msg=StringReplace($msg,":(", '<img src="' & $SmilieDir & '\sad.gif">') $msg=StringReplace($msg,"(h)",'<img src="' & $SmilieDir & '\cool.gif">') $msg=StringReplace($msg,":|", '<img src="' & $SmilieDir & '\eek.gif">') $msg=StringReplace($msg,":x", '<img src="' & $SmilieDir & '\mad.gif">') $msg=StringReplace($msg,":$", '<img src="' & $SmilieDir & '\shame.gif">') $msg=StringReplace($msg,":s", '<img src="' & $SmilieDir & '\confused.gif">') $msg=StringReplace($msg,";)", '<img src="' & $SmilieDir & '\wink.gif">') $Previous= _IEDocReadHTML($XT_oIE) ;~ $Previous & _IEDocWriteHTML($XT_oIE, $Previous & '<font color="blue" size="3"><i>' & @UserName & ' says:</i></font><br><font color="' & $color & '" size=' & $size & '>' & $msg & '</font><br>') EndFuncI already tried $oIE.document.parentwindow.scroll but it looks really.. bad. Can anyone think of a better way? Edited November 23, 2007 by Nahuel Link to comment Share on other sites More sharing options...
DaleHohm Posted November 23, 2007 Share Posted November 23, 2007 I have a solution to exactly this in the forum somewhere, but can't find it at the moment. You may want to search and I will try more later. Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
Nahuel Posted November 23, 2007 Author Share Posted November 23, 2007 Thank you for your reply Dale I've looked a lot before posting, but none of the answers was convincing. This is the 'best' one I found:$iVisibleHeight = $XT_oIE.document.body.clientHeight $XT_oIE.document.parentwindow.scrollBy(0,$iVisibleHeight)It has the same 'up and down' effect which makes it really annoying, and it gets worse as the text grows.$oIE.document.body.clientHeight always returns the same value, obviously, no matter how much text there is in the window. So 'removing' (somehow) the same quantity of rows of text from the top as they are appended seems a bit hard now...Thank you for your help. Link to comment Share on other sites More sharing options...
Will66 Posted November 23, 2007 Share Posted November 23, 2007 If i understand the issue correctly....you could place a bookmark <a name="bottom"> in the ie and insert your new entry above the bookmark then navigate to about:blank#bottom Link to comment Share on other sites More sharing options...
Nahuel Posted November 23, 2007 Author Share Posted November 23, 2007 Sure, that sounds nice... But I have the feeling that it will cause the same problem, I'll try it. The problem is that the new text is not appended to the end. The old text is read and attached to the new one and then set to the IE object, which causes it to scroll up. Navigating to about:blank#bottom will cause it to scroll down again, causing that 'up-down' effect I mentioned Link to comment Share on other sites More sharing options...
DaleHohm Posted November 23, 2007 Share Posted November 23, 2007 My screen updates fast enough it took me a bit to understand what you were having issues with. It's the screen flicker as it updates from the top and then scrolls down to the bottom right? If so, an this is actually much more efficient anyway, use _IEDocInsertHTML instead of *WriteHTML. The folllowing modification adds a new line in the main section and rewrites and removes lines in your update function: expandcollapse popup#include <GUIConstants.au3> #include <IE.au3> $XT_oIE = _IECreateEmbedded() $MainGui = GUICreate("Chat",624, 446) $Obj_RCV = GUICtrlCreateObj($XT_oIE, 6, 20, 600, 346) _IENavigate($XT_oIE, "about:blank") $oBody = _IETagNameGetCollection($XT_oIE, "body", 0) ; <---------- This is new $EditSend = GUICtrlCreateEdit("",6, 374, 539, 61, $WS_VSCROLL) $Send = GUICtrlCreateButton("Send", 556, 382, 57, 53, $BS_DEFPUSHBUTTON) GUICtrlSetState($EditSend,$GUI_FOCUS) GUISetState(@SW_SHOW) $begin = TimerInit() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Send XSkinText(GUICtrlRead($EditSend)) GUICtrlSetData($EditSend,"") GUICtrlSetState($EditSend,$GUI_FOCUS) EndSwitch WEnd Func XSkinText($msg = "", $color = "black", $size = "3") If $msg == "/clr" Then Return _IEDocWriteHTML($XT_oIE, "") If $msg == "/exit" Then Exit If StringInStr($msg,"/goto:",1) Then $URL=StringSplit($msg,":") Return _IENavigate($XT_oIE,StringStripWS($URL[2],8) ,0) EndIf ;Smilies $SmilieDir=@ScriptDir & "\caritas" $msg=StringReplace($msg,":)", '<img src="' & $SmilieDir & '\smile.gif">') $msg=StringReplace($msg,":D", '<img src="' & $SmilieDir & '\smile.gif">') $msg=StringReplace($msg,":(", '<img src="' & $SmilieDir & '\sad.gif">') $msg=StringReplace($msg,"(h)",'<img src="' & $SmilieDir & '\cool.gif">') $msg=StringReplace($msg,":|", '<img src="' & $SmilieDir & '\eek.gif">') $msg=StringReplace($msg,":x", '<img src="' & $SmilieDir & '\mad.gif">') $msg=StringReplace($msg,":$", '<img src="' & $SmilieDir & '\shame.gif">') $msg=StringReplace($msg,":s", '<img src="' & $SmilieDir & '\confused.gif">') $msg=StringReplace($msg,";)", '<img src="' & $SmilieDir & '\wink.gif">') ; Start New code $sAppend = '<font color="blue" size="3"><i>' & @UserName & ' says:</i></font><br><font color="' & $color & '" size=' & $size & '>' & $msg & '</font><br>' _IEDocInsertHTML($oBody, $sAppend) $iVisibleHeight = $XT_oIE.document.body.clientHeight $XT_oIE.document.parentwindow.scrollBy(0, $iVisibleHeight) ; End New code EndFunc Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
Nahuel Posted November 23, 2007 Author Share Posted November 23, 2007 You Dale, are my personal hero That's just perfect. Thanks a bunch for your time and great solutions, as always. 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