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.
Need help with inserting controls
Dear Alex,
You could add the following source in the OnSelect event of your TRichViewEdit (C++) to retreive information from a component:
To replace the caption of a TLabel:
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);
}
}
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);
}
}