Call GetSelectionBounds from OnItemAction

General TRichView support forum. Please post your questions here
Post Reply
vit
Posts: 115
Joined: Tue Feb 03, 2009 3:11 pm

Call GetSelectionBounds from OnItemAction

Post by vit »

Hi!

Sometimes I get exception when I try to call GetSelectionBounds from OnItemAction event handler. So I have 2 questions:

1. It is allowably to call GetSelectionBounds from OnItemAction?
2. How can I determine is document formatted?

Thank you!
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

No, you cannot use methods related to selection from this event, because document can be unformatted and even half-created.

Sorry, there is no way to guarantee that the document is formatted.
vit
Posts: 115
Joined: Tue Feb 03, 2009 3:11 pm

Post by vit »

Sergey Tkachenko wrote:document can be unformatted and even half-created.
I guess that doc can be half-created while it is loading? Or not only?
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

When this event informs about item insertion, this insertion may be done in many ways, including file cleared.
Similarly, deletion may means that the document is being loaded.
In these cases, document may be half-created or half-destroyed when this event is called.
And in the most cases, this event is called then the document is not formatted, so it is not ready to be displayed, modified, and its selection cannot be accessed.
vit
Posts: 115
Joined: Tue Feb 03, 2009 3:11 pm

Post by vit »

Ok.

I'm going to do the next.
1. When ItemAction = rviaInserting in OnItemAction event handler I will put Item into the TObjectList. Then I will post some message to the form.
2. Also I will add item deletion processing to OnItemAction to exclude item from TObjectList.
3. In message handler I will get Item from TObjectList.

So can I be sure that in message handler Item will not be freed?
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

If you use PostMessage, and quickly add and delete item, a message will be processed after deletion.
Post Reply