Jump to content

Gui Edit Line Question


torels
 Share

Recommended Posts

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

Hi there

I 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 it

can anybody help ?

thanks in advance

what u mean with "same line" ?

are u italian??

Edited by oMBra
Link to comment
Share on other sites

made an example :P

#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

yes I am... is it so evident ? XD

thanks ProgAndy :(

Edit: I noticed now you are italian to :P

Edited 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

ProgAndy

torels

Good example, but 2 notes:

1. High CPU usage.

2. Doesn't work for both edit control.

My example:

#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

:P

Link to comment
Share on other sites

Well, didn't have the time to do it properly :P 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 :idea:

#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 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

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 :P

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

Well, didn't have the time to do it properly :P 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 :idea:

#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

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 :P

*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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...