Jump to content

SOLVED: Scrolling, Read only, text display using Edit not Input Control


Lope
 Share

Recommended Posts

I need an Input Control that's Read only, white background, black text, with Scrolling.

When I try use $ES_READONLY it goes grey and forces it to be single line...

$ES_MULTILINE+$WS_VSCROLL looks good, but I need read only behaviour.

I've looked in the help & searched the forums, can't find anything...

Edited by Lope
Link to comment
Share on other sites

  • Moderators

Lope,

First a question: What is the use of a Read-Only Input? :idea: An Input control is designed to be written in!

Secondly, an Input is by definition a single line Edit control, so it is not surprising you are running into problems when you try to scroll down. :(

What exactly are you trying to do? Perhaps we can offer another solution. :)

M23

Edit: Typnig again........

Edited by Melba23

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:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Lope IMHO you need ComboBox not input .If i understand correct your question...

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

#Region ### START Koda GUI section ### Form=Form1.kxf
$Form1 = GUICreate("Form1", 633, 264, 192, 124)
$Combo1 = GUICtrlCreateCombo("", 176, 112, 265, 25, BitOR($WS_VSCROLL,$ES_READONLY,$CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
GUICtrlSetBkColor(-1,0xFFFFFF) ;white background color


For $i=1 to 100
    GUICtrlSetData($Combo1,$i & "|" )
    Next

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
[size="5"] [/size]
Link to comment
Share on other sites

Thanks for the replies.

I'm doing a license agreement box in my program.

The user needs to be able to read all the text, scrolling down as they read through it, then click a box saying 'I accept the terms' etc.

See attachment. I've got it working, but I need it to be read only behaviour.

When I set read only it goes grey and single line...

Any suggestions, like on right click, or on keypress it just overwrites the textbox with a variable again?

GUICtrlCreateInput("blah" & @CRLF & "blah etc",$offsetx_content,$offsety_content+50,$width_contentarea,$height_contentarea-50,$ES_MULTILINE+$WS_VSCROLL)

;I'm trying to find out when the user clicks the control, or types in it, because then I can overwrite it with the original text...
While 1
switch GUIGetMsg()
  case $myinputhandle                 ;can't get this to fire...
    msgbox (0,"foo","bar")
EndSwitch
WEnd

post-57474-12723199462474_thumb.jpg

Edited by Lope
Link to comment
Share on other sites

As Melba already told, Input is SingleLine Edit Box, thats why you cant input multiline data in input box by default. My advice would be try to use GUICtrlCreateEdit. Its same as GUICtrlCreateInput, just it would create Edit Box, which would allow to enter multiline data by default.

For changing grey to white, you may simple use GUICtrlSetBkColor([Edit box],0xFFFFFF).

For the last question you may try HotKeySet. If you want to use any buttom from your soft, you could use either the way with GUIGetMsg, either GUIOnEventMode. For me GUIOnEventMode way looks better, so its what i am using.

By the way, dont know how about others, but i am too lazy to write a code just for testing what you want, so it would be good if you add just a part of script which i could compile and test what you get.

Edited by Makaule
Link to comment
Share on other sites

  • Moderators

Lope,

Now we know what you want......: :(

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

; Generate long text
$sText = "blah" & @CRLF
For $i = 1 To 7
    $sText &= $sText
Next

; Create GUI
$hGUI = GUICreate("Test", 500, 500)

GUICtrlCreateLabel("Agree or else!", 10, 10, 200, 20)

GUICtrlCreateEdit($sText, 10, 40, 480, 200, BitOr($WS_VSCROLL, $ES_READONLY))

$hButton = GUICtrlCreateButton("Close", 210, 460, 80, 30)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $hButton
            Exit
    EndSwitch

WEnd

Note you have to use BitOr to combine the styles. If you use a particular style, you overwrite any existing styles, so you must make sure you include all those you require. And why BitOR? Because most of the styles are set at a the bit level (look at the values in the Help file) and merely adding the values risks setting bits you do not want. :)

Ask if anything is unclear. :idea:

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:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Lope,

Now we know what you want......: :(

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

; Generate long text
$sText = "blah" & @CRLF
For $i = 1 To 7
    $sText &= $sText
Next

; Create GUI
$hGUI = GUICreate("Test", 500, 500)

GUICtrlCreateLabel("Agree or else!", 10, 10, 200, 20)

GUICtrlCreateEdit($sText, 10, 40, 480, 200, BitOr($WS_VSCROLL, $ES_READONLY))

$hButton = GUICtrlCreateButton("Close", 210, 460, 80, 30)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $hButton
            Exit
    EndSwitch

WEnd

Note you have to use BitOr to combine the styles. If you use a particular style, you overwrite any existing styles, so you must make sure you include all those you require. And why BitOR? Because most of the styles are set at a the bit level (look at the values in the Help file) and merely adding the values risks setting bits you do not want. :)

Ask if anything is unclear. :idea:

M23

Excellent! I wanted to start another thread on this too but discovered this. I always had problems with the $ES_READONLY style. The vertical scrolling bar was enabled even though the input data was shorter than the input space and it was impossible to move it. Similarly if the input data was longer than the input space, the scrolling bar was activated but I couldn't move it therefore preventing me from reading the hidden input data to the right.

I was using $WS_VSCROLL, $ES_AUTOVSCROLL, $ES_MULTILINE, $ES_WANTRETURN, $ES_READONLY

Maybe the styles I was using was overwriting one another(no BitOr maybe) but your script worked great! Thank you!

Link to comment
Share on other sites

Thanks guys, you're like AutoIt ninjas :idea:

Last night after posting I thought of trying this with a label! lol (trying to add a scrollbar to a label)

Works perfectly with the edit control :) thanks

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