DarkBoost Posted December 2, 2009 Share Posted December 2, 2009 When adding the Style WS_VSCROLL it breaks the ES_READONLY - any suggestions? #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 Link to comment Share on other sites More sharing options...
martin Posted December 2, 2009 Share Posted December 2, 2009 When adding the Style WS_VSCROLL it breaks the ES_READONLY - any suggestions? #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. #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. Link to comment Share on other sites More sharing options...
DarkBoost Posted December 2, 2009 Author Share Posted December 2, 2009 That works perfectly... thank you! Link to comment Share on other sites More sharing options...
ProgAndy Posted December 2, 2009 Share Posted December 2, 2009 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* [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 Link to comment Share on other sites More sharing options...
martin Posted December 2, 2009 Share Posted December 2, 2009 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. Link to comment Share on other sites More sharing options...
Basicz Posted February 19, 2010 Share Posted February 19, 2010 (edited) 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() == "+"). $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. Edit: Does i hijacking this thread when i ask about this? If yes then i open my own. basicz Edited February 20, 2010 by Basicz [right]Sorry for my poor english(dictionary beside)[/right][center]Search before ask will helping the community of AutoIt.[/center][center]...seeking in the search forum and help-file's, with all the most answer's that i need. Hope for you too.[/center] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 20, 2010 Moderators Share Posted February 20, 2010 Basicz,Often using BitOR and simple addition will give you the same answer, but sometimes not. 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. 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 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Basicz Posted February 20, 2010 Share Posted February 20, 2010 Basicz,Often using BitOR and simple addition will give you the same answer, but sometimes not. 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. 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. M23Hi M23,That's very clear about BitOr() and normal addition. For the future i'm will using only BitOr(). Thank you very much, to explain this. I'm appreciate. basicz [right]Sorry for my poor english(dictionary beside)[/right][center]Search before ask will helping the community of AutoIt.[/center][center]...seeking in the search forum and help-file's, with all the most answer's that i need. Hope for you too.[/center] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now