Sign in to follow this  
Followers 0
Zest

Inputbox text alignment always left but still scrollable

3 posts in this topic

#1 ·  Posted (edited)

Hello,

In a database viewer I have made inputboxes in a GUI, which are filled out with text from an array (containing the database). The text in the inputbox is changed when selecting different data from the database.

The text is often longer than the size of the inputbox

What I want is the following :

- Single line Inputbox

- No scrollbars

- Text is always left-aligned, so that the leftmost character is always visible

- Text is scrollable, so that when the user has activated the editbox and scrolls to the right beyond the limits of the inputbox, the text scrolls to the left and into view

- Text is read-only

- Background colour is white

I just can't get all of these to work at once

Here's a snippet of my current code as example:

#include <GuiConstants.au3>
$MainGUI = GuiCreate("TEST", 400, 100)
GuiSetState()

; Title label and inputbox
$TitleInput=GUICtrlCreateInput("", 10, 30, 150, 20,bitor($SS_SUNKEN,$ES_READONLY,$ES_AUTOHSCROLL))
GUICtrlSetBkColor (-1, 0xFFFFFF)
;Example of setting the data in the inputbox which shifts the text to the left
GUICtrlSetData($TitleInput,"This is a very long line with more text than fits into the inputbox")

While 1
    $msg = GUIGetMsg()
; Exit through close button
    If $msg = $GUI_EVENT_CLOSE Then
        Exit
    EndIf
WEnd

The only thing not working yet is gettting the text to be left-aligned every time the data in the inputbox is updated. How can this be done?

Thanks in advance!

Edited by Zest

Share this post


Link to post
Share on other sites



Hello,

In a database viewer I have made inputboxes in a GUI, which are filled out with text from an array (containing the database). The text in the inputbox is changed when selecting different data from the database.

The text is often longer than the size of the inputbox

What I want is the following :

- Single line Inputbox

- No scrollbars

- Text is always left-aligned, so that the leftmost character is always visible

- Text is scrollable, so that when the user has activated the editbox and scrolls to the right beyond the limits of the inputbox, the text scrolls to the left and into view

- Text is read-only

- Background colour is white

I just can't get all of these to work at once

Here's a snippet of my current code as example:

#include <GuiConstants.au3>
$MainGUI = GuiCreate("TEST", 400, 100)
GuiSetState()

; Title label and inputbox
$TitleInput=GUICtrlCreateInput("", 10, 30, 150, 20,bitor($SS_SUNKEN,$ES_READONLY,$ES_AUTOHSCROLL))
GUICtrlSetBkColor (-1, 0xFFFFFF)
;Example of setting the data in the inputbox which shifts the text to the left
GUICtrlSetData($TitleInput,"This is a very long line with more text than fits into the inputbox")

While 1
    $msg = GUIGetMsg()
; Exit through close button
    If $msg = $GUI_EVENT_CLOSE Then
        Exit
    EndIf
WEnd

The only thing not working yet is gettting the text to be left-aligned every time the data in the inputbox is updated. How can this be done?

Thanks in advance!

If you just want the text in the input box to show from the first character then include GUIEDIT.AU3 and use

_GUICtrlEdit_SetSel($TitleInput,0,0) when the text has been updated. I think that will do it.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Thanks!

Works great! :)

Kind of weird though, to have to use such a trick for something so simple... (or is there a another way maybe?)

Share this post


Link to post
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
Sign in to follow this  
Followers 0