Re: Delete control by code

Return to index



Christian Kirchhoff

Posted: 01/28/2003 18:36:16


thanks for the support, I'm one step further now. But I have another question.

I declared all the imported properties of my control as "published", so they

are saved to the stream and restored later. But I've also assigned prcoedures

to some mouse events, which are not restored.

And because the (deleted and newly) inserted control is different from the

original inserted control, FindControlItemNo doesn't find it any more.

What is the easiest way to find this control again, so I can assign the mosue

events to it again?


Christian Kirchhoff

"Sergey Tkachenko" <> wrote:

>> Hello,


>> The only way I could think of to delete a control inserted in a


>> seems to be the DeleteItems procedure, but I receive an exception if I


>> to do that.

>> Is DeleteItems not allowed for controls?


>It's allowed. But you need to call Format method before displaying document.

>But there is another problem - DeleteItems is a "viewer-style" method. It

>does not update undo buffer, and it will be damaged after its call.



>> I would need that first of all in order to let the user delete a control

>> by choosing a command in a popup menu (and not only by moving the caret


>> the right of the control and pressing BACKSPACE).

>> Second, I would like to implement my own Drag&Drop of controls inside


>> RichViewEditor. While dragging the control, I move the caret to the actual

>> mosue position inside the RichViewEditor. In the OnDragDrop event I have

>> the dragged control as the parameter "Source". I don't think it is


>> to move controls or other items directly from on position to another,


>> what I would do is create a new control of the same type, assign the


>> to it in order to make a copy, delete the original control out of the


>> and insert the new control at the current position of the caret.

>> But if deleting controls with code does not work there seems to be nothing

>> I could do.

>> Does anyone have an idea?


>I suggest deleting control by selecting it (SetSelectionBounds) and calling


>So you need:

>1) when starting dragging, store the control position

>2) when finishing dragging, store the destination position

>3) select the original control (using information of step 1) and delete


>4) move the caret to the location stored on step 2 and insert a new control


>Some ideas:

>- control can be copied by selecting it and calling SaveRVFToStream, then

>inserting by InsertRVFFromStreamEd

>- positions can be stored by functions RVGetSelection and RVSetSelection






>> Regards,


>> Christian Kirchhoff



Powered by ABC Amber Outlook Express Converter