Page 1 of 1

Problem inserting TComboBox and TListBox in richviewedit

Posted: Fri Sep 08, 2006 1:40 am
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.

Posted: Fri Sep 08, 2006 6:49 pm
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.

Posted: Mon Sep 11, 2006 5:32 pm
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!