trichview.com

trichview.support




Re: SelectAll+Repaint = Access Violation


Return to index


Author

Message

Sergey Tkachenko

Posted: 03/30/2004 17:32:31


This is a known problem. You cannot destroy VCL control from inside its

keyboard event.

(it's looks like this is not an event of trichviewedit but the event of the

form, but this is wrong; in KeyPreviewMode controls call form's OnKeyDown

event from their own keyboard handling procedures).

RichViewEdit.SelectAll destroys the active control (cell inplace editor),

and AV occurs.

There is no solution of this problem from the side of the component.


But you can

1) instead of using OnKeyDown, assign this shortcut to menu or actions

or

2) in OnKeyDown, use PostMessage to post your own message to the form. Call

SelectAll in the message handler (I can make an example, if you need)



> Hello.

>

> You can reproduce strange access violation in such way:

> 1. Open Delphi\Editors\Editor1 demo

> 2. Form1.KeyPreview set to true

> 3. Add this code in Form1.OnKeyDown:

>   if (key=65) and (ssCtrl in shift) then begin

>    richviewedit1.selectall;

>    richviewedit1.repaint; // even if you delete this line, bug will

persist

>   end;

> 4. Run Demo, clear all the text, and add any table

> 5. Put cursor into any table cell and press Ctrl-A. You'll get access

> violation.

>

> How can I quickly fix this bug?





Powered by ABC Amber Outlook Express Converter