Sign in to follow this  
Followers 0
Floppy

EditBox Font

15 posts in this topic

Hi,

I have an editbox with some text, how can i change the font in editbox...for example, some text BOLD, other ITALIC, etc.

Thanks in advance

Share this post


Link to post
Share on other sites



look up all the guictrlset functions in autoit.


Giggity

Share this post


Link to post
Share on other sites

I can write the GuiCtrlSet... function in the script...I would to create a program like MS Word.

For example, if in the editbox there is the phrase:

HELLO WORLD!

I can change the HELLO word to green, and the WORLD word to red, like this:

HELLO WORLD!

Share this post


Link to post
Share on other sites

:):(:o:(:D:(:D:(:D:(:(:(

Is there another way?

Otherwise, thank you...

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I can write the GuiCtrlSet... function in the script...I would to create a program like MS Word.

You know how long they spend creating Word? :)

I can change the HELLO word to green, and the WORLD word to red, like this:

You need a richtext control to do that. :o Edited by Kip

Share this post


Link to post
Share on other sites

You know how long they spend creating Word? :)

You need a richtext control to do that. :o

Yes, but I want to create a program similar Word, not exactly the same...

Share this post


Link to post
Share on other sites

You have to use a RichEdit instead of an Edit. Look in my sig for an UDF :) It's an extended version of the one created by Kip.


*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

Share this post


Link to post
Share on other sites

:):o:D:D:D:(

It's very long. Can you explain how can I use it, please?

Share this post


Link to post
Share on other sites

Is this really so difficult?

1) Create the RichEdit with _GUICtrlRichEdit_Create

2) use the functions like _GUICtrlRichEdit_SetBold, _GUICtrlRichEdit_SetItalic, _GUICtrlRichEdit_SetFontName for your buttons :)

Most functions are listed here: http://pastebin.com/f7f2a956b


*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

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Is this really so difficult?

1) Create the RichEdit with _GUICtrlRichEdit_Create

2) use the functions like _GUICtrlRichEdit_SetBold, _GUICtrlRichEdit_SetItalic, _GUICtrlRichEdit_SetFontName for your buttons :)

Most functions are listed here: http://pastebin.com/f7f2a956b

it works, but when i'm trying to toggle bold...it doesn't toggle really...maybe the script is wrong...look please:

#include <GuiConstants.au3>
#Include <GuiEdit.au3>
#include <GuiRichEdit.au3>

$gui=GUICreate("Html Editor",1000,500)
$edit=GUICtrlCreateEdit("",10,50,480,440)
$rich=_GUICtrlRichEdit_Create($gui,505,50,480,440)
$bold=GUICtrlCreateButton("B",10,10,30,30)
GUISetState(@SW_SHOW)


While 1
    $m=GUIGetMsg()
    Select
    Case $m=$gui_event_close
        ExitLoop
    Case $m=$bold
        $test=_GUICtrlRichEdit_SetBold($rich,False)
    EndSelect
WEnd

thanks and bye!!!

Edited by FSoft

Share this post


Link to post
Share on other sites

First, you have to select a font which has bold and standard style and set it to default. Then you can use the funcs :)

#include <GuiConstants.au3>
#Include <GuiEdit.au3>
#include <GuiRichEdit.au3>

$gui=GUICreate("Html Editor",1000,500)
$edit=GUICtrlCreateEdit("",10,50,480,440)
$rich=_GUICtrlRichEdit_Create($gui,505,50,480,440)
$bold=GUICtrlCreateButton("B",10,10,30,30)
GUISetState(@SW_SHOW)
_GUICtrlRichEdit_SetBold($rich,False,False)
_GUICtrlRichEdit_SetFontName($rich,"Arial",False)


While 1
    $m=GUIGetMsg()
    Select
    Case $m=$gui_event_close
        ExitLoop
    Case $m=$bold
        If _GUICtrlRichEdit_GetBold($rich) Then
            _GUICtrlRichEdit_SetBold($rich,False)
        Else
            _GUICtrlRichEdit_SetBold($rich,True)
        EndIf
    EndSelect
WEnd

*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

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Bold works...

Sorry for the questions...but now ITALIC and UNDERLINE don't works :o (I don't WHY?)...I'm used the same code of the BOLD...look

#include <GuiConstants.au3>
#Include <GuiEdit.au3>
#include <GuiRichEdit.au3>;~ see http://pastebin.com/f7f2a956b

$gui=GUICreate("Html Editor",1000,500)
$edit=GUICtrlCreateEdit("",10,50,480,440)
$rich=_GUICtrlRichEdit_Create($gui,505,50,480,440)
$bold=GUICtrlCreateButton("B",10,10,30,30)
$italic=GUICtrlCreateButton("I",40,10,30,30)
$underline=GUICtrlCreateButton("U",70,10,30,30)
GUISetState(@SW_SHOW)
_GUICtrlRichEdit_SetFontName($rich,"Arial",False)
_GUICtrlRichEdit_SetBold($rich,False,False)
_GUICtrlRichEdit_SetItalic($rich,False,False)
_GUICtrlRichEdit_SetLink($rich,False,False)


While 1
    $m=GUIGetMsg()
    Select
    Case $m=$gui_event_close
        ExitLoop
    Case $m=$bold
        If _GUICtrlRichEdit_GetBold($rich) Then
            _GUICtrlRichEdit_SetBold($rich,False)
        Else
            _GUICtrlRichEdit_SetBold($rich,True)
        EndIf
    Case $m=$italic
        If _GUICtrlRichEdit_SetItalic($rich) Then
            _GUICtrlRichEdit_SetItalic($rich,False)
        Else
            _GUICtrlRichEdit_SetItalic($rich,True)
        EndIf   
    Case $m=$underline
        If _GUICtrlRichEdit_SetLink($rich) Then
            _GUICtrlRichEdit_SetLink($rich,False)
        Else
            _GUICtrlRichEdit_SetLink($rich,True)
        EndIf   
    EndSelect
WEnd

sorry for bother... :) bye and thanks

Edited by FSoft

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Don't forget to use _GUICtrlRichEdit_Get... in if-statement :)

//Edit: use _GUICtrlRichEdit_SetUnderline for underline, not Link. This creates Link-styled text.

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

Share this post


Link to post
Share on other sites
I'M VERY VERY SILLY :) . Now works...thank you very much...BYE! :o

Share this post


Link to post
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
Sign in to follow this  
Followers 0