trichview.support
Re: How to select a Control by clicking a button |
Author |
Message |
Pieter E. |
Posted: 11/14/2004 23:14:21 Dear Sergey, The code you gave me, doesn't do what I want. I've got the following code: void __fastcall TForm1::Button1Click(TObject *Sender) { TEdit* edt = new TEdit((TComponent*)NULL); edt->OnClick = OnControlClick; rve->InsertControl("", edt, rvvaBaseline); if(rve->CurItemStyle == rvsComponent) rve->SetCurrentItemExtraIntProperty(rvepResizable, 1, True); } //--------------------------------------------------------------------------- When I click the button, a TEdit shows on the TRichViewEdit. The TEdit isn't selected. The TEdit should be selected after pressing the button. Could you give me a hint? Thanks. Pieter E. "Sergey Tkachenko" <[email protected]> wrote: >There is a method SelectControl(). > >You can look how to implement selecting components when clicking on them in >the Demos\CBuilder\Editors\Editor 1\ demo: > > >//-------------------------------------------------------------------------- >- >// Event: clicking inserted controls >void __fastcall TForm1::OnControlClick(TObject *Sender) >{ > RichViewEdit1->SelectControl((TControl*)Sender); >} >//-------------------------------------------------------------------------- >- >// Insert|Component|Button >// (I modified the code for control insertion, because >// in the new version InsertControl() returns a boolean >// value and it's easy to understand if the control was >// inserted) >void __fastcall TForm1::mitButtonCompClick(TObject *Sender) >{ > ... > TButton* btn = new TButton((TComponent*)NULL); > ... > btn->OnClick = OnControlClick; > if (RichViewEdit1->InsertControl("",btn,rvvaBaseline)) > RichViewEdit1->SetCurrentItemExtraIntProperty(rvepResizable, 1, True); >} >//-------------------------------------------------------------------------- >- >void __fastcall TForm1::RichViewEdit1ControlAction(TCustomRichView *Sender, > TRVControlAction ControlAction, int ItemNo, TControl *&ctrl) >{ > if (ControlAction==rvcaAfterRVFLoad) > { > ... > if (ctrl->InheritsFrom(__classid(TButton))) > ((TButton*)ctrl)->OnClick = OnControlClick; > else if (ctrl->InheritsFrom(__classid(TEdit))) > ((TEdit*)ctrl)->OnClick = OnControlClick; > } > ... >} > > > > > >> >> I'd like to select a component by clicking a button. I use the following >code >> for adding a component: >> >> TEdit* edt = new TEdit((TComponent*)NULL); >> edt->Text = "This is a test"; >> edt->OnClick = OnControlClick; >> rve->InsertControl("", edt, rvvaBaseline); >> if (rve->CurItemStyle == rvsComponent) >> rve->SetCurrentItemExtraIntProperty(rvepResizable, 1, True); >> >> Thanks. >> >> Pieter E. > > |
Powered by ABC Amber Outlook Express Converter