Problem inserting TComboBox and TListBox in richviewedit

General TRichView support forum. Please post your questions here
Post Reply
VT
Posts: 18
Joined: Mon Jul 31, 2006 1:39 pm

Problem inserting TComboBox and TListBox in richviewedit

Post by VT »

I am having problems on inserting the controls TComboBox and TListBox in richviewedit. I'm using the following code:

var
listbox : TListBox;
begin
listbox : TListBox.create(self);
rve.insertcontrol('', listbox, rvvaBaseline);
end;

When I execute it, a exception is raised, "Control has no parent window". I tried set a parent, but the error continues.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I cannot reproduce this problem.
I created a new project, placed TRichViewEdit and TRVStyle on form, added your code in FormCreate, it worked.
Pieter E.
Posts: 835
Joined: Sun Aug 28, 2005 9:34 am

Post by Pieter E. »

Did you register the 'TComboBox'-class before inserting using 'RegisterClasses'?

You set the owner of the 'TListBox' to 'self'. Maybe it is better to typecast nihil to a 'TComponent'.

In C++ it look like this:

Code: Select all

Call this once:
TComponentClass Classes[1] = { __classid(TComboBox };
RegisterClasses(Classes, 0);

Add the following lines into the 'OnClick'-event from a 'TButton':
TComboBox *cmbbx = new TComboBox((TComponent*)NULL);
cmbbx->Style = csDropDownList;
cmbbx->Font->Name = "Arial";
cmbbx->Font->Size = 8;
cmbbx->Font->Color = clBlack;
cmbbx->OnChange = OnChangeComponents;
if(RichViewEdit->InsertControl(aControlInfo, cmbbx, rvvaBaseline))
{
RichViewEdit->SetCurrentItemExtraIntProperty(rvepResizable, 1, true);
cmbbx->Items->Clear();
cmbbx->Items->Add("Option 1");
cmbbx->Items->Add("Option 2");
cmbbx->Items->Add("Option 3");
cmbbx->ItemIndex = 0;
RichViewEdit->Format();
RichViewEdit->SelectControl(cmbbx);
}
Good luck!
Post Reply