Jump to content



Photo

[SOLVED] Edit control: vertical scroll + read-only


  • Please log in to reply
4 replies to this topic

#1 Mingre

Mingre

    Adventurer

  • Active Members
  • PipPip
  • 100 posts

Posted 27 April 2012 - 04:53 AM

Hello Forums,

How do I render the edit control with a vertical scroll and also make it read-only?

In the helpfile, the syntax for edit control is:
GUICtrlCreateEdit ( "text", left, top [, width [, height [, style [, exStyle]]]] )


I'm guessing that both $WS_VSCROLL and $ES_READONLY should be on the style parameter though I don't know how to combine them.

Here's my script: (Please don't mind the unneccessary "includes".)
AutoIt         
#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <string.au3> #include <array.au3> #include <EditConstants.au3> #include <Misc.au3> $Form = GUICreate('Uhm', 500, 500, 0,0, $WS_BORDER) GUISetCursor(2) ;GUISetBkColor(0x000000) $_History = GUICtrlCreateEdit('Lorem ipsum', 8, 8, 400, 400,  $WS_VSCROLL , $ES_READONLY) ; <<<<<<<< ;$_History = GUICtrlCreateEdit('Lorem ipsum', 8, 8, 400, 400,   $ES_READONLY, $WS_VSCROLL) ;$_History = GUICtrlCreateEdit('Lorem ipsum', 8, 8, 400, 400,  $ES_READONLY) ;$_History = GUICtrlCreateEdit('Lorem ipsum', 8, 8, 400, 400,  $WS_VSCROLL) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x000000) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg   Case $GUI_EVENT_CLOSE    Exit EndSwitch WEnd


Thanks!

Edit: Added "[SOLVED]" to title.

Edited by Lilbert, 27 April 2012 - 05:07 AM.








#2 Mingre

Mingre

    Adventurer

  • Active Members
  • PipPip
  • 100 posts

Posted 27 April 2012 - 05:05 AM

Hello again,

I just learned a workaround.

AutoIt         
#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <string.au3> #include <array.au3> #include <EditConstants.au3> #include <Misc.au3> $Form = GUICreate('Uhm', 500, 500, 0,0, $WS_BORDER) GUISetCursor(2) ;GUISetBkColor(0x000000) #include <GuiEdit.au3>; <<<<<<<<<<<< $_History = GUICtrlCreateEdit('Lorem ipsum', 8, 8, 400, 400,  $WS_VSCROLL ) _GUICtrlEdit_SetReadOnly($_History, True) ;<<<<<<<< GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x000000) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg   Case $GUI_EVENT_CLOSE    Exit EndSwitch WEnd


Problem solved. Thanks people!

#3 guinness

guinness

    guinness

  • MVPs
  • 11,013 posts

Posted 27 April 2012 - 07:51 AM

Use BitOR to combine styles...
#include <GUIConstantsEx.au3> #include <GUIEdit.au3> #include <WindowsConstants.au3> Example() Func Example()     Local $hGUI = GUICreate('Uhm', 500, 500, -1, -1)     Local $iEdit = GUICtrlCreateEdit('Lorem ipsum', 5, 5, 490, 485, BitOR($ES_READONLY, $WS_VSCROLL)) ; Use BitOR to combine styles.     GUISetState(@SW_SHOW, $hGUI)     While 1         Switch GUIGetMsg()             Case $GUI_EVENT_CLOSE                 ExitLoop         EndSwitch     WEnd EndFunc   ;==>Example

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_DesktopDimensions()_DisplayPassword()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_Icon_Clear()/_Icon_Set()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringIsValid()_StringReplaceWholeWord()_StringStripChar()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()AutoIt SearchAutoIt3 PortableAutoItWinGetTitle()/AutoItWinSetTitle()CodingFileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasteBinSciTE JumpSignature CreatorWM_COPYDATAMore Examples...Updated: 11/04/2013


#4 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,409 posts

Posted 27 April 2012 - 10:57 AM

Use BitOR to combine styles...

...     Local $iEdit = GUICtrlCreateEdit('Lorem ipsum', 5, 5, 490, 485, BitOR($ES_READONLY, $WS_VSCROLL)) ; Use BitOR to combine styles. ...

Even more correct way is to use $GUI_SS_DEFAULT_EDIT
... $_History = GUICtrlCreateEdit('Lorem ipsum', 8, 8, 400, 400, BitOr($GUI_SS_DEFAULT_EDIT, $ES_READONLY, $WS_VSCROLL)) ; <<<<<<<< ...

Edited by Zedna, 27 April 2012 - 10:57 AM.


#5 guinness

guinness

    guinness

  • MVPs
  • 11,013 posts

Posted 27 April 2012 - 11:37 AM

Even more correct way is to use $GUI_SS_DEFAULT_EDIT

... $_History = GUICtrlCreateEdit('Lorem ipsum', 8, 8, 400, 400, BitOr($GUI_SS_DEFAULT_EDIT, $ES_READONLY, $WS_VSCROLL)) ; <<<<<<<< ...

Yeh True. Thanks.

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_DesktopDimensions()_DisplayPassword()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_Icon_Clear()/_Icon_Set()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringIsValid()_StringReplaceWholeWord()_StringStripChar()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()AutoIt SearchAutoIt3 PortableAutoItWinGetTitle()/AutoItWinSetTitle()CodingFileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasteBinSciTE JumpSignature CreatorWM_COPYDATAMore Examples...Updated: 11/04/2013





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users