Jump to content

RichText Control, 31 functions!


Kip
 Share

Recommended Posts

I have one reproach, your commands for adding text in RichEdit not supports UniCode Characters, demo:

#Include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <GuiRichEdit.au3>

$GUI = GUICreate("bye",700,500)
    
     $hRichText = RichText_Create($GUI, 0, 0, 700, 500)
     RichText_InsertText($hRichText, "Hello everybody"& @CRLF)
    
GUISetState()

RichText_SetSel($hRichText, 6, 11); Pos 6 to 11 is 'every'
RichText_SetColor($hRichText, 0x0000FF, True); True = colorize selection, False = colorize all.  !!! Color codes is BGR !!!
RichText_SetSel($hRichText, 20, 20); Set the selection to 0-0

RichText_InsertText($hRichText, ChrW(263)&" "&ChrW(269))
MsgBox(0, "Added characters:", ChrW(263)&" "&ChrW(269))
While 1
     If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
WEnd
Edited by n3nE

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Link to comment
Share on other sites

  • Replies 47
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

One quick suggestion ...

Get the formatted RTF text from the control (RichText_GetText only returns unformatted text)

Really good work, keep it up :)

My scripts:AppLauncherTRAY - Awesome app launcher that runs from the system tray NEW VERSION! | Run Length Encoding - VERY simple compression in pure autoit | Simple Minesweeper Game - Fun little game :)My website

Link to comment
Share on other sites

I have some examples and an own RichEdit UDf, but not completly finished :)

//Edit: If compiled as Unicde it will use Unicode to get/add text, otherwise ANSI ( CP_ACP)

Edited by ProgAndy

*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

Hello, i have a few new questions...

1. Is possible to made funcions fot setting color,bold,font etc.. without selecting text than to set start number of character and end for setting color,bold... something like this:

RichText_SetColor($hRichText, $hColor, $i_start, $i_end)

2. Is possible to made func RichText_CharFromPos ( i tried but failed^^ )

3. How to add hyperlink in this RichEdit ? I tried but i don't know how to control that hyperlink ^^

Func RichText_SetHyperlink($hWnd, $hBold = False, $iSelec = 0x01)
    Local $tcharformat, $pCHARFORMAT
    $tcharformat = _tagCHARFORMAT2()
    DllStructSetData ($tcharformat, "cbSize", DllStructGetSize($tcharformat))
    DllStructSetData($tcharformat, "dwMask", $CFM_LINK)
    If $hBold Then
        DllStructSetData ($tcharformat, "dwEffects", $CFE_LINK)
    Else
        DllStructSetData ($tcharformat, "dwEffects", 0)
    EndIf
    $pCHARFORMAT = DllStructGetPtr($tcharformat)
    Return _SendMessage ($hWnd, $EM_SETCHARFORMAT, $iSelec, $pCHARFORMAT)
EndFunc

Edit: Sry for very bad english :)

Edited by n3nE

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Link to comment
Share on other sites

1. Is possible to made funcions fot setting color,bold,font etc.. without selecting text than to set start number of character and end for setting color,bold... something like this:

RichText_SetColor($hRichText, $hColor, $i_start, $i_end)

You can't. Something that would do the same:

RichText_PauseRedraw($hRichText)
$aPos = RichText_GetSel($hRichText)
RichText_SetSel($hRichText, $i_start, $i_end)
RichText_SetColor($hRichText, $iColor)
RichText_SetSel($hRichText, $aPos[1], $aPos[0])
RichText_ResumeRedraw($hRichText)

2. Is possible to made func RichText_CharFromPos ( i tried but failed^^ )

A character pos, or X and Y pos?

3. How to add hyperlink in this RichEdit ? I tried but i don't know how to control that hyperlink ^^

$EM_SETCHARFORMAT isnt a suported EM_SETCHARFORMAT mask. Try this:

Func RichText_AutoURLDetect($hWnd, $iMode=True)
    Return _SendMessage ($hWnd, $EM_AUTOURLDETECT, $iMode, 0)
EndFunc

An EN_LINK notification will be send if a link is clicked.

Link to comment
Share on other sites

A character pos, or X and Y pos?

Yes, same like for Edit.

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>

$hwnd = GUICreate("Form1", 633, 447, -1, -1)
$pic = GUICtrlCreatePic("", 0, 0, 600, 400)
$Edit1 = GUICtrlCreateEdit("", 0, 0, 600, 400)
GUICtrlSetData(-1, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" &@CRLF& "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
$lbl = GUICtrlCreateLabel("", 20, 410, 200, 30)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $pic
            $mpos = _WinAPI_GetMousePos(True, $hwnd)
            $pos = _GUICtrlEdit_CharFromPos($Edit1, DllStructGetData($mpos, "X"), DllStructGetData($mpos, "Y"))
            GUICtrlSetData($lbl, "Character pos: "&$pos[0] &@CRLF& "Line number: " & $pos[1])
            _GUICtrlEdit_SetSel($Edit1, $pos[0], $pos[0])
    EndSwitch
WEnd

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Link to comment
Share on other sites

  • 1 month later...

Have you tried _GUICtrlEdit_CharFromPos($hRichText, 100, 20) ? Almost all edit functions can be used with RichText.

Yes, and for every $x and $y i get same number of character and line...

Why?!

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Link to comment
Share on other sites

Well, RichEdit needs other Parameter and return value is different ...

Ii try to implement OLE interface in AuoIt. If i get it, i'll post my RichEdit UDF :mellow:

Edited by ProgAndy

*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

Thank you for answer, I'm waiting for yout UDF :-)

Btw... Just one more question for this RichEdit UDF, how to get selected text?

I know for RichText_GetText, but it's for All text...

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Link to comment
Share on other sites

Good job man, now give me example how to colorize text by givenword, for example, i want all words "FOR", "AND","NEXT" to be in blue color. How would i do that?

Will this be added in next release of autoit? it would be nice.

Edited by au3scr
Link to comment
Share on other sites

Kip, where is answer on my question? :mellow:

I need to get only selected text...

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

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