Jump to content

Coloured text


Recommended Posts

Richedit not edit controls

There is an example in the beta help file I believe.

Gary

I found the example:

; Rich edit control EXAMPLE using GUICtrlCreateObj

; Author: Kåre Johansson
; AutoIt Version: 3.1.1.55
; Description: Very Simple example: Embedding RICHTEXT object
; Needs: MSCOMCT2.OCX in system32 but it's probably already there
; Date: 3 jul 2005

#include <GUIConstants.au3>

$oRP = ObjCreate("RICHTEXT.RichtextCtrl.1")

GUICreate("Embedded RICHTEXT control Test", 320, 200, -1, -1,BitOr($WS_OVERLAPPEDWINDOW,$WS_VISIBLE,$WS_CLIPSIBLINGS))
$TagsPageC = GuiCtrlCreateLabel('Visit Tags Page', 5, 180, 100, 15, $SS_CENTER)
GuiCtrlSetFont($TagsPageC,9,400,4)
GuiCtrlSetColor($TagsPageC,0x0000ff)
GuiCtrlSetCursor($TagsPageC,0)
$AboutC = GUICtrlCreateButton('About',105,177,70,20)
$PrefsC = GUICtrlCreateButton('FontSize',175,177,70,20)
$StatC = GUICtrlCreateButton('Plain Style',245,177,70,20)

$GUIActiveX = GUICtrlCreateObj( $oRP, 10, 10 , 400 , 260 )
GUICtrlSetPos($GUIActiveX,10,10,300,160)

With $oRP; Object tag pool
.OLEDrag()
.Font = 'Arial'
.text = "Hello - Au3 supports ActiveX components like the RICHTEXT thanks to SvenP" & @CRLF & 'Try write some text and quit to reload'
;.FileName = @ScriptDir & '\RichText.rtf'
;.BackColor = 0xff00
EndWith

GUISetState ();Show GUI

While 1
    $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
            $oRP.SaveFile( @ScriptDir & "\RichText.rtf", 0 )
            ExitLoop
        Case $msg = $TagsPageC
            Run(@ComSpec & ' /c start http://www.myplugins.info/guids/typeinfo/typeinfo.php?clsid={3B7C8860-D78F-101B-B9B5-04021C009402}','', @SW_HIDE)
        Case $msg = $AboutC
            $oRP.AboutBox() 
        Case $msg = $PrefsC
            $oRP.SelFontSize = 12
            
        Case $msg = $StatC
            $oRP.SelBold = False
            $oRP.SelItalic = False
            $oRP.SelUnderline = False 
            $oRP.SelFontSize = 8
    EndSelect
WEnd

However, I am no COM master. I tried the .SelText method but it just inserts the string at the beginning of the edit control. Could you point me in the direction of a highlight method?

Thanks in advance and regards

Link to comment
Share on other sites

Gary

I found the example:

[autoit]; Rich edit control EXAMPLE using GUICtrlCreateObj

; Author: Kåre Johansson

; AutoIt Version: 3.1.1.55

; Description: Very Simple example: Embedding RICHTEXT object

; Needs: MSCOMCT2.OCX in system32 but it's probably already there

; Date: 3 jul 2005

Didn't appear to be what I need. I mean a way to make the text enterd in an edit control show in different pre-determined colours as in programmers editors like Crimson Editor, Scite etc. Thanks all the same!
Link to comment
Share on other sites

Didn't appear to be what I need. I mean a way to make the text enterd in an edit control show in different pre-determined colours as in programmers editors like Crimson Editor, Scite etc. Thanks all the same!

I think Gary meant that a Rich Edit control will allow the functionality that you desire. The example that I posted needs to be extended.
Link to comment
Share on other sites

  • 2 years later...

That is exactly what Gary has said. It is a RICHEDIT not an EDIT control that will give you that functionality. Search for it, because there are a few different examples around the place.

I didn't think it was that hard to understand :D

Cheers,

Brett

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