Sign in to follow this  
Followers 0
BugsRUs

How to? - Edit Control hold a string larger than visible field?

7 posts in this topic

I've got my Gui going with couple Edit Controls. Single line...

I want them to be able to accept/store strings longer than are displayable in the controls dimension, and scroll with cursor movement if necessary. However currently once the visible space is full, it stops accepting input.

Any Ideas?

I thought of possibly defining it initially larger than my final view, then resize the Gui in a way that shrinks my displayed edit field in the smaller size I'm after, but I'm not sure if that will work.

The Help on the Style and exStyle seem confused. The Style field actually seems to be reacting to the Static Control constants rather than the EditConstants, And I'm not having any luck fooling with the exStyle field at all.

Thanks

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Maybe you set a limit to the control using GUICtrlSetLimit(). Default the edit controls have no limits.

Best is show us your code.

Br,

UEZ

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

No limit set on purpose. In fact tried to use GUICtrlSetLimit() to establish a limit larger than the field holds. But that did not work..

Here is the code...

;-------------------------------------------------------------------------------;

; Inlude Region ;

;-------------------------------------------------------------------------------;

#Include <String.au3>

#Include <Array.au3>

#include <GUIConstantsEx.au3>

#include <GuiToolbar.au3>

#include <EditConstants.au3>

#include <WindowsConstants.au3>

#include <StaticConstants.au3>

;-------------------------------------------------------------------------------;

; Global Variable and Constant Initializations

;-------------------------------------------------------------------------------;

; Control IDs and Control elements related to the GUI needed in global domain

Global $GuiWindow ; Handle for the GUI Window in case needed outside the gui setup function

Global $URLBorID ; control ID of GUIs group border around edit field

Global $URLRectID ; control ID of GUIs edit field white rectangle

Global $URLMsg = "" ; Holder for the Script Status Message

;-------------------------------------------------------------------------------;

; Main Core Script

;

;-------------------------------------------------------------------------------;

SetUpGui() ; Creates the GUI

While 1

sleep(1000)

WEnd

StopScript() ; shuts down socket and UDP and any files

;-------------------------------------------------------------------------------;

; SetUpGui()

; Create and populate the GUI Window

; Assign functions to stop script buttons

;-------------------------------------------------------------------------------;

Func SetUpGui()

; GUI Window size

Local $GuiWidth = 800

Local $GuiHeight = 230

;Control 2 - Group Border around the URL Edit Field

Local $URLBorL = 5

Local $URLBorT = 5

Local $URLBorW = 575

Local $URLBorH = 35

;Control 3 - URL EDIT Field- white rectangle

Local $URLRecL = $URLBorL + 5

Local $URLRecT = $URLBorT + 11

Local $URLRecW = $URLBorW - 10

Local $URLRecH = $URLBorH - 15

;Control 8 - STOP script Button

Local $StopButtonL = 20

Local $StopButtonT = $URLBorT+$URLBorH+40

Local $StopButtonW = 75

Local $StopButtonH = 30

Opt("GUIOnEventMode", 1) ; Sets Gui Mode for "OnEvent Interrupt"

$GuiWindow = GUICreate("Gallery Scanner", $GuiWidth, $GuiHeight,-1,-1,$WS_OVERLAPPEDWINDOW) ; Create GUI Window

GUISetOnEvent($GUI_EVENT_CLOSE, "StopScript")

;Setup the URL Area

$URLBorID = GUICtrlCreateGroup("Target URL:", $URLBorL, $URLBorT, $URLBorW, $URLBorH,$SS_ETCHEDFRAME) ; creates labled border

GUICtrlSetFont( $URLBorID, 8 , 400 , 1 )

GUICtrlSetResizing($URLBorID, $GUI_DOCKLEFT+$GUI_DOCKTOP+$GUI_DOCKHEIGHT)

$URLRectID = GUICtrlCreateEdit("", $URLRecL, $URLRecT, $URLRecW, $URLRecH ,0x1006) ;0x1006 = sunken+white rectangle - sunken rectangle to hold text

GUICtrlSetFont( $URLRectID, 10 , 400 , 1 , "Tahoma" , 5)

GUICtrlSetResizing($URLRectID, $GUI_DOCKLEFT+$GUI_DOCKTOP+$GUI_DOCKHEIGHT)

;Setup Stop Script Button

$StopButtonID = GUICtrlCreateButton("Stop and Exit", $StopButtonL ,$StopButtonT,$StopButtonW,$StopButtonH) ;create Button

GUICtrlSetOnEvent($StopButtonID,"StopScript") ; go to stopscript function if clicked

GUICtrlSetResizing($StopButtonID, $GUI_DOCKALL)

GUISetState(@SW_SHOW)

Return

EndFunc

;-------------------------------------------------------------------------------;

; StopScript()

; Stops script

;-------------------------------------------------------------------------------;

Func StopScript()

MsgBox(0,"Test Script","Do you want to exit?")

Exit

EndFunc

;-------------------------------------------------------------------------------;

Share this post


Link to post
Share on other sites

There are problems with that script, the style for the edit box doesn't do what you think it does. The style value you show equals the following styles

$ES_MULTILINE 0x0004

$ES_RIGHT 0x0002

$ES_WANTRETURN 0x1000

If you make the dimensions of your edit box larger, so that the box is taller, you will see that the text wraps to the next line but because you only have it large enough for one line to show, the cursor never moves off of the first line.

Not exactly sure what you meant by this comment after the Edit creation code "0x1006 = sunken+white rectangle - sunken rectangle to hold text" because that's not what that does for an edit box.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

0x1006 is not sunken+white rectangle - sunken!

It is:

0x1000 = $ES_WANTRETURN

0x0004 = $ES_MULTILINE

0x0002 = $ES_RIGHT

You mixed up the styles for the edit control.

Br,

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

I just realized, you used the values for the $SS_xx constants in the $ES_xx constants style settings. The $SS_xx styles only apply to Label/Icon/Pic controls, you can't use them in an edit control.

And this is a good example of why you should avoid using numerical values (magic numbers) in place of constants, you won't confuse them later in your scripts.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

OK.... sorry... That was a leftover bit from a previous script that was using a Label instead of an Edit.

If I just drop the style fields, it seems ok. Takes strings longer than I need.

Thanks.

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