Thread: *TLabel at runtime

  1. #1
    Registered User subdene's Avatar
    Join Date
    Jan 2002
    Posts
    367

    *TLabel at runtime

    Hi, i need to be able to create a TLabel at runtime, and some how either associate the Label with the form, or the form with the label, or maybe even both i'm not quite sure. I've tried the following:

    Code:
    TLabel *Text;
    Text = new TLabel(NULL);
    
    Text->Parent = DestForm //contains address of the form
    
    Text->Caption = "Test";
    Test->Visible = true;
    I've had luck though.... thanks is advance.
    Be a leader and not a follower.

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

    Post

    What's your question? Your code seems OK.

    You might want to set the Left & Top properties. You can also assign the TLabel's parent to anything derived from TWinControl not just a form. I.e. you can make it's parent a TPanel.

  3. #3
    Registered User subdene's Avatar
    Join Date
    Jan 2002
    Posts
    367
    I've tried using the code, but the label will not appear on the form. btw i omitted the left and top, i also set the font name , color, size etc. It just won't seem to work, also tried passing the address of the form in the label's constructor, but that didn't work either. Test = new TLabel(this);
    Be a leader and not a follower.

  4. #4
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812
    >Test = new TLabel(this);

    You shouldn't need to do this.

    I've used this technique & had no problems with it. When I get home (I'm away from my PC at the moment), I'll send you some code.

    All I can suggest is that you ensure that when placing the TLabel on your form, there is nothing covering it's position, such as TPanel.
    OS: Windows XP
    Compilers: MinGW (Code::Blocks), BCB 5

    BigAngryDog.com

  5. #5
    Registered User subdene's Avatar
    Join Date
    Jan 2002
    Posts
    367
    Hi, thanks for your time. It's working now...... I was setting the TLabel to NULL by accident! , which is probably why it wasn't working! stupid! never mind!
    Be a leader and not a follower.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Runtime formation and execution at runtime
    By Soham in forum C Programming
    Replies: 17
    Last Post: 08-27-2008, 08:45 AM
  2. link with C runtime library
    By George2 in forum C++ Programming
    Replies: 26
    Last Post: 02-05-2008, 01:56 AM
  3. Visual Studio and .Net Runtime Framework dependency
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 08-08-2007, 07:52 AM
  4. Change a control class during runtime
    By Joelito in forum Windows Programming
    Replies: 3
    Last Post: 01-12-2006, 02:13 PM
  5. FILES in WinAPI
    By Garfield in forum Windows Programming
    Replies: 46
    Last Post: 10-02-2003, 06:51 PM