Jump to content

Recommended Posts

Posted

When I open a GUI that has an Input box, and the text for that box is long, the text has scrolled all the way to the right. I would like it to show the beginning of the text rather than the end. So I have to click inside the box and press Home to read the beginning.

Is there a way to do make it scroll left in the Input box?

Posted

Maybe this thread helps

My UDFs and Tutorials:

  Reveal hidden contents

 

  • Moderators
Posted

DickG,

Or perhaps like this:

#include <GUIConstantsEx.au3>

$sText = "A nice long string to get the input scrolled to the right"

$hGUI = GUICreate("Test", 500, 500)

$cInput = GUICtrlCreateInput($sText, 10, 10, 200, 20)

GUISetState()

ControlSend($hGUI, "", $cInput, "{HOME}")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

This Google search will return similar results.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted
  On 1/1/2016 at 8:37 PM, water said:

Maybe this thread helps

Awesome! That works great! I could not find anything on this forum when I typed "cursor position input box". I was not aware of the _GUICtrlEdit_SetSel() command. I guess searching the AutoIt forums gives me better results from Google! :-)

Thanks much, water.

Posted

Correct. At the moment Google gives the best search results as the forums search feature is awful since the last upgrade :(
Did you try the solution Melba provided? I think this is even more elegnat as it doesn't need to include a whole UDF.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted (edited)

My idea:

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

AutoItSetOption("GUIOnEventMode", 1)

Global Const $hGUI = GUICreate("Test", 232, 90)
Global Const $iInput = GUICtrlCreateInput("", 42, 30, 140), $hInput = GUICtrlGetHandle($iInput)
Global Const $iButton = GUICtrlCreateButton("OK", 190, 50, 32, 32)
GUISetState()

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

While Sleep(100)
WEnd

Func _Exit()
    GUIDelete()
    Exit
EndFunc

Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg
    Local $iIDFrom = _WinAPI_LoWord($iwParam)
    Local $iCode = _WinAPI_HiWord($iwParam)
    Local $sInput, $aPosCtrl, $aPosWin
    Switch $ilParam
        Case $hInput
            Switch $iCode
                Case $EN_SETFOCUS
                    ControlClick($hGUI, "", $iInput, "", 1, 1)
                Case $EN_CHANGE
                    $sInput = GUICtrlRead($iInput)
                    If StringLen($sInput) > 22 Then
                        $aPosWin = WinGetPos($hGUI)
                        $aPosCtrl = ControlGetPos($hGUI, "", $iInput)
                        ToolTip($sInput, -100 + $aPosWin[0] + $aPosCtrl[0], $aPosWin[1] + $aPosCtrl[1])
                    EndIf
                Case $EN_KILLFOCUS
                    ToolTip("")
            EndSwitch
    EndSwitch
    Return "GUI_RUNDEFMSG"
EndFunc   ;==>WM_COMMAND

 

Edit: forget it, I got you wrong -> new year hangover :drinks:

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted
  On 1/1/2016 at 8:38 PM, Melba23 said:

DickG,

Or perhaps like this:

#include <GUIConstantsEx.au3>

$sText = "A nice long string to get the input scrolled to the right"

$hGUI = GUICreate("Test", 500, 500)

$cInput = GUICtrlCreateInput($sText, 10, 10, 200, 20)

GUISetState()

ControlSend($hGUI, "", $cInput, "{HOME}")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

M23

Thanks, Melba. I tried it, but couldn't get it to work. I must be doing something wrong because your sample does indeed work. But the _GUICtrlEdit_SetSel() command works for me, so I'll be using that.

Posted
  On 1/1/2016 at 9:36 PM, mikell said:

:)

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>

$sText = "A nice long string to get the input scrolled to the right"

$hGUI = GUICreate("Test", 300, 100)
$cInput = GUICtrlCreateInput($sText, 10, 10, 200, 20)
GUISetState()
GuiCtrlSendMsg($cInput, $EM_SETSEL, 0, 0)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Awesome!

GuiCtrlSendMsg($cInput, $EM_SETSEL, 0, 0) also works great! Now I have two great ways to do this!

Thanks much, mikell!

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
  • Recently Browsing   0 members

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