torels Posted October 17, 2008 Share Posted October 17, 2008 Hi there I have 2 edit controls in a gui, and I want them to be always at the same line My problem is here: How do I set the first visible line of an edit ? I know how to tetrieve the first visible line... but can't figure out how to set it can anybody help ? thanks in advance Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org Link to comment Share on other sites More sharing options...
oMBRa Posted October 17, 2008 Share Posted October 17, 2008 (edited) Hi thereI have 2 edit controls in a gui, and I want them to be always at the "My problem is here:How do I set the first visible line of an edit ?I know how to tetrieve the first visible line... but can't figure out how to set itcan anybody help ?thanks in advancewhat u mean with "same line" ?are u italian?? Edited October 17, 2008 by oMBra Link to comment Share on other sites More sharing options...
ProgAndy Posted October 17, 2008 Share Posted October 17, 2008 made an example #AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GuiEdit.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> _Main() Func _Main() Local $hEdit1, $hEdit, $hGUI Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir") & "\include\changelog.txt" ; Create GUI $hGUI = GUICreate("Edit Scroll", 800, 300) $hEdit1 = GUICtrlCreateEdit("", 2, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL)) $hEdit = GUICtrlCreateEdit("", 400, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL)) GUISetState() ; Set Text _GUICtrlEdit_SetText($hEdit, FileRead($sFile)) _GUICtrlEdit_SetText($hEdit1, FileRead($sFile)) Local $sel Do _SendMessage(GUICtrlGetHandle($hEdit),$EM_LINESCROLL,0,_GUICtrlEdit_GetFirstVisibleLine($hEdit1)-_GUICtrlEdit_GetFirstVisibleLine($hEdit)) Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Main how it works: use em_linescroll and difference from edit1 fisrtline and edit2 first line *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
torels Posted October 17, 2008 Author Share Posted October 17, 2008 (edited) yes I am... is it so evident ? XD thanks ProgAndy Edit: I noticed now you are italian to Edited October 17, 2008 by torels Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org Link to comment Share on other sites More sharing options...
oMBRa Posted October 17, 2008 Share Posted October 17, 2008 (edited) ciao allora sei il primo italiano che vedo, cmq cosa intendevi con same line? Edited October 17, 2008 by oMBra Link to comment Share on other sites More sharing options...
rasim Posted October 18, 2008 Share Posted October 18, 2008 ProgAndytorelsGood example, but 2 notes:1. High CPU usage.2. Doesn't work for both edit control.My example:expandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiEdit.au3> Global $aPos $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir") & "\include\changelog.txt" ; Create GUI $hGUI = GUICreate("Edit Scroll", 800, 300) $hEdit1 = GUICtrlCreateEdit("", 2, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL)) $hEdit2 = GUICtrlCreateEdit("", 400, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL)) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUISetState() ; Set Text _GUICtrlEdit_SetText($hEdit1, FileRead($sFile)) _GUICtrlEdit_SetText($hEdit2, FileRead($sFile)) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_PRIMARYUP $aPos = GUIGetCursorInfo($hGUI) If IsArray($aPos) Then _Scroll($aPos[4]) EndSwitch WEnd Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam) Local $iID Local $nCtl = BitAND($wParam, 0x0000FFFF) Local $nCode = BitShift($wParam, 16) Switch $nCode Case $EN_VSCROLL Switch $nCtl Case $hEdit1 $iID = $hEdit2 Case $hEdit2 $iID = $hEdit1 EndSwitch EndSwitch GUICtrlSendMsg($iID, $EM_LINESCROLL, 0, _GUICtrlEdit_GetFirstVisibleLine($nCtl) - _GUICtrlEdit_GetFirstVisibleLine($iID)) Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func _Scroll($sCtl) If $sCtl = $hEdit1 Then GUICtrlSendMsg($hEdit2, $EM_LINESCROLL, 0, _GUICtrlEdit_GetFirstVisibleLine($hEdit1) - _GUICtrlEdit_GetFirstVisibleLine($hEdit2)) ElseIf $sCtl = $hEdit2 Then GUICtrlSendMsg($hEdit1, $EM_LINESCROLL, 0, _GUICtrlEdit_GetFirstVisibleLine($hEdit2) - _GUICtrlEdit_GetFirstVisibleLine($hEdit1)) Else Return False EndIf EndFunc ;==>_Scroll Link to comment Share on other sites More sharing options...
Andreik Posted October 18, 2008 Share Posted October 18, 2008 Nice example Rasim. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
ProgAndy Posted October 18, 2008 Share Posted October 18, 2008 (edited) Well, didn't have the time to do it properly So i just made a quick solution, which at least worked So, Rasim thanks for your example. //Edit: but you can still simplify the WM_COMMAND expandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiEdit.au3> Global $aPos $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir") & "\include\changelog.txt" ; Create GUI $hGUI = GUICreate("Edit Scroll", 800, 300) $hEdit1 = GUICtrlCreateEdit("", 2, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL)) $hEdit2 = GUICtrlCreateEdit("", 400, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL)) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUISetState() ; Set Text _GUICtrlEdit_SetText($hEdit1, FileRead($sFile)) _GUICtrlEdit_SetText($hEdit2, FileRead($sFile)) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_PRIMARYUP $aPos = GUIGetCursorInfo($hGUI) If IsArray($aPos) Then _Scroll($aPos[4]) EndSwitch WEnd Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam) Local $iID Local $nCtl = BitAND($wParam, 0x0000FFFF) Local $nCode = BitShift($wParam, 16) Switch $nCode Case $EN_VSCROLL _Scroll($nCtl) EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func _Scroll($sCtl) If $sCtl = $hEdit1 Then GUICtrlSendMsg($hEdit2, $EM_LINESCROLL, 0, _GUICtrlEdit_GetFirstVisibleLine($hEdit1) - _GUICtrlEdit_GetFirstVisibleLine($hEdit2)) ElseIf $sCtl = $hEdit2 Then GUICtrlSendMsg($hEdit1, $EM_LINESCROLL, 0, _GUICtrlEdit_GetFirstVisibleLine($hEdit2) - _GUICtrlEdit_GetFirstVisibleLine($hEdit1)) Else Return False EndIf EndFunc ;==>_Scroll Edited October 18, 2008 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
rasim Posted October 18, 2008 Share Posted October 18, 2008 ProgAndybut you can still simplify the WM_COMMANDYou are right. Thanks Link to comment Share on other sites More sharing options...
torels Posted October 18, 2008 Author Share Posted October 18, 2008 ciao allora sei il primo italiano che vedo, cmq cosa intendevi con same line?Intendevo Impostare le prime righe visibili dei 2 edit alla stessa riga @rasim & Progandy thank you Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org Link to comment Share on other sites More sharing options...
torels Posted October 18, 2008 Author Share Posted October 18, 2008 Well, didn't have the time to do it properly So i just made a quick solution, which at least worked So, Rasim thanks for your example. //Edit: but you can still simplify the WM_COMMAND expandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiEdit.au3> Global $aPos $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir") & "\include\changelog.txt" ; Create GUI $hGUI = GUICreate("Edit Scroll", 800, 300) $hEdit1 = GUICtrlCreateEdit("", 2, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL)) $hEdit2 = GUICtrlCreateEdit("", 400, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL)) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUISetState() ; Set Text _GUICtrlEdit_SetText($hEdit1, FileRead($sFile)) _GUICtrlEdit_SetText($hEdit2, FileRead($sFile)) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_PRIMARYUP $aPos = GUIGetCursorInfo($hGUI) If IsArray($aPos) Then _Scroll($aPos[4]) EndSwitch WEnd Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam) Local $iID Local $nCtl = BitAND($wParam, 0x0000FFFF) Local $nCode = BitShift($wParam, 16) Switch $nCode Case $EN_VSCROLL _Scroll($nCtl) EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func _Scroll($sCtl) If $sCtl = $hEdit1 Then GUICtrlSendMsg($hEdit2, $EM_LINESCROLL, 0, _GUICtrlEdit_GetFirstVisibleLine($hEdit1) - _GUICtrlEdit_GetFirstVisibleLine($hEdit2)) ElseIf $sCtl = $hEdit2 Then GUICtrlSendMsg($hEdit1, $EM_LINESCROLL, 0, _GUICtrlEdit_GetFirstVisibleLine($hEdit2) - _GUICtrlEdit_GetFirstVisibleLine($hEdit1)) Else Return False EndIf EndFunc ;==>_Scroll A question, I don't understand the code here What does WM_COMMAND do ?? XD Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org Link to comment Share on other sites More sharing options...
ProgAndy Posted October 18, 2008 Share Posted October 18, 2008 The WM_COMMAND informs the parent window of commands performed in the controls. Now, if the action is a scroll, it calls the _Scroll function to scroll the other edit, too *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
rasim Posted October 19, 2008 Share Posted October 19, 2008 torelsMSDN 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