Need help with inserting controls

General TRichView support forum. Please post your questions here
Post Reply
IGDark
Posts: 41
Joined: Wed Jan 18, 2006 11:03 am

Need help with inserting controls

Post by IGDark »

Hello,
I need to insert some components inside TRichViewEdit (TLabel & TProgressBar). I use AddControlEx function for this purpose. However, I also need to have an access to these components. Ex. I need to change a caption of one of the labels inside.
Could somebody plz give me an example of how I can find my TLabel and TProgressBar inside RichEdit, and change their properties?
The perfect case would be if you tell me how I can find the components by their names.

P.S. I tried to use FindChildControl() but it works ONLY with progress bars, but not with labels.

Thanks,
Alex.
Pieter E.
Posts: 834
Joined: Sun Aug 28, 2005 9:34 am

Post by Pieter E. »

Dear Alex,

You could add the following source in the OnSelect event of your TRichViewEdit (C++) to retreive information from a component:

Code: Select all

if(rve->CurItemNo < 0) return;
if(rve->CurItemStyle == rvsComponent)
  {
    AnsiString aName;
    TControl *aCtrl;
    TRVVAlign AVAlign;
    int iTag;
    int iIndex;
    rve->GetCurrentControlInfo(aName, aCtrl, AVAlign, iTag);
    if(aCtrl->InheritsFrom(__classid(TLabel)))
      {
         ShowMessage(((TLabel *)aCtrl)->Caption);
      }
  }
To replace the caption of a TLabel:

Code: Select all

if(rve->CurItemStyle == rvsComponent)
  {
    AnsiString aName;
    TControl *aCtrl;
    TRVVAlign AVAlign;
    int iTag;
    int iIndex;
    rve->GetCurrentControlInfo(aName, aCtrl, AVAlign, iTag);
    if(aCtrl->InheritsFrom(__classid(TLabel)))
      {
         ((TLabel *)aCtrl)->Caption = "Hello World";
         rve->SetCurrentControlInfo(aName, AVAlign, iTag);
         rve->Format();
         rve->SelectControl(aCtrl);
      }
  }
IGDark
Posts: 41
Joined: Wed Jan 18, 2006 11:03 am

Post by IGDark »

Thanks, that does help!
Post Reply