Board index » cppbuilder » changing font characteristics from a font button in a RichEdit combobox

changing font characteristics from a font button in a RichEdit combobox

I have a   program with a RichEdit  combobox and I need to highlight the
particular text and then do a right click of the mouse or click on the font
button, change the font characteristics of just the highlighted text and
then apply it either when the apply button is clicked or the OK button is
clicked.  Right now, all I have been able to do is to change the font
characteristics of all the text reguardless of whether any text is
highlighted or not.  Any help would be appreciated.

          Thanks,

                 Roger

 

Re:changing font characteristics from a font button in a RichEdit combobox


Hi Roger,

Quote
> I have a   program with a RichEdit  combobox and I need to highlight the
> particular text and then do a right click of the mouse or click on the font
> button, change the font characteristics of just the highlighted text and
> then apply it either when the apply button is clicked or the OK button is
> clicked.

Use the TRichEdit::SelSttributes property to manipulate the text attributes of
the selected text.  Here's a rough example...

void __fastcall TForm1::FontDialog1Apply(TObject *Sender, HWND Wnd)
{
    RichEdit1->SelAttributes->Assign(FontDialog1->Font);

Quote
}

void __fastcall TForm1::ChooseFontButtonClick(TObject *Sender)
{
    if (FontDialog1->Execute())
    {
        FontDialog1Apply(NULL, NULL);
    }    

Quote
}

Good luck!

--
Damon Chandler (TeamB)
http://bcbcaq.freeservers.com

Re:changing font characteristics from a font button in a RichEdit combobox


Damon;

    Thanks alot for the info, it works great.

        Roger

Damon Chandler (TeamB) <dm...@cornell.edu> wrote in message
news:38F0AD38.AA70B631@cornell.edu...

Quote
> Hi Roger,
> > I have a   program with a RichEdit  combobox and I need to highlight the
> > particular text and then do a right click of the mouse or click on the
font
> > button, change the font characteristics of just the highlighted text and
> > then apply it either when the apply button is clicked or the OK button
is
> > clicked.

> Use the TRichEdit::SelSttributes property to manipulate the text
attributes of
> the selected text.  Here's a rough example...

> void __fastcall TForm1::FontDialog1Apply(TObject *Sender, HWND Wnd)
> {
>     RichEdit1->SelAttributes->Assign(FontDialog1->Font);
> }

> void __fastcall TForm1::ChooseFontButtonClick(TObject *Sender)
> {
>     if (FontDialog1->Execute())
>     {
>         FontDialog1Apply(NULL, NULL);
>     }
> }

> Good luck!

> --
> Damon Chandler (TeamB)
> http://bcbcaq.freeservers.com

Other Threads