Thread: Borland C++ Builder question

  1. #1
    Registered User
    Join Date
    Jun 2004
    Posts
    7

    Borland C++ Builder question

    Hi,
    I just wanted to know how to change the font style of a control in C++ Builder on the fly. For example, suppose that the following occurs:

    TPanel* Panel;
    Panel = new TPanel(Form1);

    //What do I write here?

    Form1->InsertControl(Panel);




    I know that, for instance, if I wanted to change the font name to Times New Roman, you would just use the following:

    Panel->Font->Name = "Times New Roman";

    But there is no analogue for changing the font style; for instance, both of the following throw errors:

    Panel->Font->Style = fsBold;
    Panel->Font->Style->fsBold = true;

    I've tried a couple other things, but nothing actually works. Any ideas?

  2. #2
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812
    Try:

    Panel->Font->Style = TFontStyles() << fsBold;

    TFontStyles is a 'Set' - a class. Essentially what you are doing is creating a new empty one, setting bold to be true and assigning the whole thing to Panel->Font->Style.
    OS: Windows XP
    Compilers: MinGW (Code::Blocks), BCB 5

    BigAngryDog.com

  3. #3
    Registered User
    Join Date
    Jun 2004
    Posts
    7
    That worked perfectly, thanks. It seems like a pretty bad implementation of that feature on the part of Borland, though, mainly because it's a bit of a departure frome the rest of the framework and they don't seem to document that syntax anywhere. Oh well, I'm glad you knew how to do it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. another do while question
    By kbpsu in forum C++ Programming
    Replies: 3
    Last Post: 03-23-2009, 12:14 PM
  2. Replies: 2
    Last Post: 10-03-2006, 04:48 PM
  3. THE END - Borland C++ Builder, Delphi, J Builder?
    By Davros in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 02-28-2006, 11:23 PM
  4. Builder Canvas & TListBox question
    By Joan Lesas in forum C++ Programming
    Replies: 5
    Last Post: 06-17-2003, 01:13 AM
  5. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM