Jump to content
Sign in to follow this  
qwert

How to left-justify input text?

Recommended Posts

qwert

I've been trying to figure a way to display long text in a short field, but have the first part of the text show -- not the last. So I prepared this test script -- but the buttons aren't clickable for a reason that I can't figure out. It's structured just like any of a dozen other scripts I use. Both buttons work when I tab to them and press Enter.

#include <GUIConstants.au3>

$GUI = GUICreate("Text Position Test", 300, 200, -1, -1)
$Label = GUICtrlCreateLabel("Long strings of displayed text need to start at the beginning ... but so do short strings.", 20, 80, 200, 60)
$Entry = GUICtrlCreateInput("", 20, 40, 200, 20)
$Key1 = GUICtrlCreateButton("Long", 50, 120, 60, 20)
$Key2 = GUICtrlCreateButton("Short", 120, 120, 60, 20)

GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Key1
            GUICtrlSetData($Entry, "This is an example of long text that exceeds the viewable area")
        Case $Key2
            GUICtrlSetData($Entry, "This is short text")
    EndSwitch
WEnd

I will appreciate a nudge on getting the buttons activated -- and then, mainly, any suggestions on how to achieve a left-justified input display.

Thanks in advance.

Edited by qwert

Share this post


Link to post
Share on other sites
ProgAndy

no, doesn't work, try this:

#include <GUIEDIT.au3>

....

        GUICtrlSetData($Entry, "This is an example of long text that exceeds the viewable area")
    _GUICtrlEdit_SetSel($Entry,0,0)

*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

Share this post


Link to post
Share on other sites
qwert

My thanks to you both. Regarding the inactive buttons, I had looked at the code for hours and didn't see the obvious. And for the positioning within the text field, I hadn't noticed the entire set of GUICtrlEdit functions before now. I'd simply not had a need to work with text within a field. They'll be very useful.

So, for anyone who might view this post, here's the working end result:

#include <GUIConstants.au3>
#include <GUIEDIT.au3>

$GUI = GUICreate("Text Position Test", 300, 200, -1, -1)
$Label = GUICtrlCreateLabel("Long strings of displayed text need to start at the beginning ... but so do short strings.", 20, 80, 200, 60)

$Entry = GUICtrlCreateInput("", 20, 40, 200, 20)
$Key1 = GUICtrlCreateButton("Long", 50, 150, 60, 20)
$Key2 = GUICtrlCreateButton("Short", 120, 150, 60, 20)

GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Key1
            GUICtrlSetData($Entry, "This is an example of long text that exceeds the viewable area")
            _GUICtrlEdit_SetSel($Entry,0,0)
        Case $Key2
            GUICtrlSetData($Entry, "This is short text")
            _GUICtrlEdit_SetSel($Entry,0,0)
    EndSwitch
WEnd

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  

×