trichview.com

trichview.support




Re: Delete control by code


Return to index


Author

Message

Christian Kirchhoff

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


Hello,


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?


Regards,


Christian Kirchhoff


"Sergey Tkachenko" <svt@trichview.com> wrote:

>> Hello,

>>

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

>TRichViewEdit

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

try

>> 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

to

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

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

the

>> 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

>possible

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

so

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

>"Source"

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

>RichViewEditor

>> 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

>DeleteSelection.

>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

it

>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

>from http://www.trichview.com/support/files/rvlinear.zip

>

>

>

>>

>> Regards,

>>

>> Christian Kirchhoff

>

>





Powered by ABC Amber Outlook Express Converter