Jump to content

Edit box indent and color


MirnesC2
 Share

Recommended Posts

Herroo!

I have two questions that I couldn't find the answer to after searching.

1. How do I indent (right,left, up, and down) the text inside an editbox? I couldn't find anything in the help files.

2. Is it possible to have multiple text colors in a single editbox? I know that GUICtrlSetColor() will change the color of the text inside an editbox but I am looking to have multiple colors in a single line. For example, the default color is white. Then I want one word in that sentence red and another orange. (Hello, my name is John)

Link to comment
Share on other sites

As far as I know it is not possible to achieve it with an edit control but using the RichtTextFormat it should be possible.

Look in the help file to find more information about RTF.

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

Link to comment
Share on other sites

Example
#AutoIt3Wrapper_Au3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiRichEdit.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Color.au3>

Opt('MustDeclareVars', 1)

Global $lblMsg, $hRichEdit

Main()

Func Main()
Local $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, 4) & ")", 320, 350, -1, -1)
$hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 300, 220, _
BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
$lblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
GUISetState()

_GUICtrlRichEdit_SetText($hRichEdit, "Hello, my name is John") ;11-14 18-22
_GUICtrlRichEdit_SetSel($hRichEdit, 10, 14)
_GUICtrlRichEdit_SetCharColor($hRichEdit, 0x0000FF)
_GUICtrlRichEdit_SetSel($hRichEdit, 17, 22)
_GUICtrlRichEdit_SetCharColor($hRichEdit, 0xdaa520)

While GUIGetMsg() <> -3
Sleep(10)
WEnd
_GUICtrlRichEdit_Destroy($hRichEdit)

EndFunc   ;==>Main

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

Example

#AutoIt3Wrapper_Au3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiRichEdit.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Color.au3>

Opt('MustDeclareVars', 1)

Global $lblMsg, $hRichEdit

Main()

Func Main()
Local $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, 4) & ")", 320, 350, -1, -1)
$hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 300, 220, _
BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
$lblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
GUISetState()

_GUICtrlRichEdit_SetText($hRichEdit, "Hello, my name is John") ;11-14 18-22
_GUICtrlRichEdit_SetSel($hRichEdit, 10, 14)
_GUICtrlRichEdit_SetCharColor($hRichEdit, 0x0000FF)
_GUICtrlRichEdit_SetSel($hRichEdit, 17, 22)
_GUICtrlRichEdit_SetCharColor($hRichEdit, 0xdaa520)

While GUIGetMsg() <> -3
Sleep(10)
WEnd
_GUICtrlRichEdit_Destroy($hRichEdit)

EndFunc ;==>Main

Excellent! My help files aren't really returning the searches I am expecting. Been having some problems with help files in general as well. Thank you for the example! :)

Also thank you for the two links in your sig! Will probably be using those as well once I am done with all the main functions of my script.

Edited by MirnesC2
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...