Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

GUICtrlCreateEdit + ReadOnly + Scrollbar?


  • Please log in to reply
7 replies to this topic

#1 DarkBoost

DarkBoost

    Adventurer

  • Active Members
  • PipPip
  • 148 posts

Posted 02 December 2009 - 02:29 AM

When adding the Style WS_VSCROLL it breaks the ES_READONLY - any suggestions?


Plain Text         
#include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) Dim $title = "gui" Dim $width = 300 Dim $height = 300 Dim $msg, $edit GUICreate($title, $width, $height) $edit = GUICtrlCreateEdit("[START]" & @CRLF, 10, 10, $width-20, $height-20, $ES_AUTOVSCROLL + $ES_READONLY) GUICtrlSetStyle($edit, $WS_VSCROLL) For $x = 1 To 50     GUICtrlSetData($edit, "add data..." & @CRLF, 1) Next GUICtrlSetData($edit, "[FINISH]", 1) GUISetState() Do     $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE








#2 martin

martin

    ~~\o/~~~/0\=¬''~~~

  • MVPs
  • 7,321 posts

Posted 02 December 2009 - 06:48 AM

When adding the Style WS_VSCROLL it breaks the ES_READONLY - any suggestions?


Plain Text         
#include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) Dim $title = "gui" Dim $width = 300 Dim $height = 300 Dim $msg, $edit GUICreate($title, $width, $height) $edit = GUICtrlCreateEdit("[START]" & @CRLF, 10, 10, $width-20, $height-20, $ES_AUTOVSCROLL + $ES_READONLY) GUICtrlSetStyle($edit, $WS_VSCROLL) For $x = 1 To 50     GUICtrlSetData($edit, "add data..." & @CRLF, 1) Next GUICtrlSetData($edit, "[FINISH]", 1) GUISetState() Do     $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE


You can make an edit readonly by sening a message to it

But in your case it is pointless if you want the user to be able to edit the control using the Enter key. The two styles $ES_AUTOVSCROLL and $ES_READONLY are not compatible and it will be the same as using $WS_VSCROLL since the user can still use the arrow keys to navigate. Even with $WS_VSCROLL the $WS_READONLY is ignored on creation so using the message was the only way I was able to make the edit readonly and have a verticle scroll bar.
It is saver BTW to BitOr styles rather thn add them which can have unexpected results.
Plain Text         
#include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> #include <sendmessage.au3> Opt("MustDeclareVars", 1) Dim $title = "gui" Dim $width = 300 Dim $height = 300 Dim $msg, $edit GUICreate($title, $width, $height) $edit = GUICtrlCreateEdit("[START]" & @CRLF, 10, 10, $width-20, $height-20, $WS_VSCROLL) GUICtrlSetStyle($edit, $WS_VSCROLL) For $x = 1 To 50     GUICtrlSetData($edit, "add data..." & @CRLF, 1) Next GUICtrlSetData($edit, "[FINISH]", 1) GUISetState() _sendmessage(ControlGetHandle("gui","",$edit),$EM_SETREADONLY,1) ;or ;_GUICtrlEdit_SetReadOnly(ControlGetHandle("gui","",$edit),True) Do     $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE

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.

#3 DarkBoost

DarkBoost

    Adventurer

  • Active Members
  • PipPip
  • 148 posts

Posted 02 December 2009 - 08:08 AM

That works perfectly... thank you!

#4 ProgAndy

ProgAndy

    You need AutoItObject

  • MVPs
  • 2,508 posts

Posted 02 December 2009 - 10:46 AM

There is no need to use GUICtrlSetStyle and SendMessage. Just use BitOr and all is fine :)
$edit = GUICtrlCreateEdit("[START]" & @CRLF, 10, 10, $width-20, $height-20, BitOR($WS_VSCROLL, $ES_AUTOVSCROLL, $ES_READONLY))

*GERMAN* Posted Image [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

#5 martin

martin

    ~~\o/~~~/0\=¬''~~~

  • MVPs
  • 7,321 posts

Posted 02 December 2009 - 12:16 PM

There is no need to use GUICtrlSetStyle and SendMessage. Just use BitOr and all is fine :)

$edit = GUICtrlCreateEdit("[START]" & @CRLF, 10, 10, $width-20, $height-20, BitOR($WS_VSCROLL, $ES_AUTOVSCROLL, $ES_READONLY))

Yes, although $ES_AUTOSCROLLL has no effect't work if $ES_READONLY is included. But the (only) advantage of sending a message is that you can change the readonly style after the edit has been created.
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.

#6 Basicz

Basicz

    Seeker

  • Active Members
  • 29 posts

Posted 19 February 2010 - 11:38 PM

Hi Martin and ProgAndy,
That's confusing me a little bit about BitOr() and "+" from this code. Isn't the final result the same ( BitOr() == "+"). :mellow:

$edit = GUICtrlCreateEdit("Texts", 10, 10, 700, 300, BitOr($WS_VSCROLL,  $ES_AUTOVSCROLL, $ES_READONLY))


and this code

$edit = GUICtrlCreateEdit("Texts", 10, 10, 700, 300, $WS_VSCROLL +  $ES_AUTOVSCROLL + $ES_READONLY)


and if i tested it, it scroll down too with "read-only" style, hmm doesn't see differents. Also read-only style works with the $ES_AUTOVSCROLL style. :(

I'm searching about tricks and technic's above with GUICtrlCreateEdit() and lead me to this topic and make me confusing about these things here.
That's because i'm using "GUICtrlCreateEdit()" in my project too and use it as output and have set the style like here but with some addition like append the text while the cursor was clicked and not at the end of the file. (that was solve)

I'm very appreciate and thank you, if someone or martin and progandy explain me again. :lol:

Edit: Does i hijacking this thread when i ask about this? If yes then i open my own.

basicz

Edited by Basicz, 20 February 2010 - 01:34 AM.

Sorry for my poor english(dictionary beside)

Posted ImageSearch before ask will helping the community of AutoIt.

...seeking in the search forum and help-file's, with all the most answer's that i need. Hope for you too.


#7 Melba23

Melba23

    I'm old - what's your excuse?

  • Moderators
  • 21,764 posts

Posted 20 February 2010 - 09:43 AM

Basicz,

Often using BitOR and simple addition will give you the same answer, but sometimes not. :lol:

Most of the styles are set using the individual bits of the style value - if you look at the Hex values of the various styles, it is pretty obvious. So using BitOR will ensure that only the correct bits are set. If you use simple addition and the particular bit is already set, you could well, depending on exactly how the addition works, unset that bit and set another. Then you end up without the style you want and with another style that is unwanted - and debugging that can take a while as I know from bitter personal exerience. :mellow:

So the advice is: Always use BitOR to combine styles - and, for exactly the same reason, use BitAND to see if a particular style is set!

I hope that clears it up. :(

M23
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
Date_Time_Convert - Easily convert date/time formats, including the language               GUIListViewEx - Insert, delete, move, drag, sort and edit ListView items

#8 Basicz

Basicz

    Seeker

  • Active Members
  • 29 posts

Posted 20 February 2010 - 09:05 PM

Basicz,

Often using BitOR and simple addition will give you the same answer, but sometimes not. :P

Most of the styles are set using the individual bits of the style value - if you look at the Hex values of the various styles, it is pretty obvious. So using BitOR will ensure that only the correct bits are set. If you use simple addition and the particular bit is already set, you could well, depending on exactly how the addition works, unset that bit and set another. Then you end up without the style you want and with another style that is unwanted - and debugging that can take a while as I know from bitter personal exerience. :mellow:

So the advice is: Always use BitOR to combine styles - and, for exactly the same reason, use BitAND to see if a particular style is set!

I hope that clears it up. :(

M23

Hi M23,

That's very clear about BitOr() and normal addition. For the future i'm will using only BitOr(). :lol:
Thank you very much, to explain this. I'm appreciate. :evil:

basicz

Sorry for my poor english(dictionary beside)

Posted ImageSearch before ask will helping the community of AutoIt.

...seeking in the search forum and help-file's, with all the most answer's that i need. Hope for you too.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users