Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

RichEdit and insert/overwrite mode

107 views
Skip to first unread message

kurc66

unread,
Oct 30, 2006, 12:36:28 PM10/30/06
to

Is it possible to detect current insert/overwrite mode in TRichEdit
component?
I'd like to show it in status bar like in Delphi IDE, but I can't find
this information on msdn.

Thanks,
Roman Kurcjusz

Remy Lebeau (TeamB)

unread,
Oct 30, 2006, 1:58:09 PM10/30/06
to

"kurc66" <nos...@nospam.com> wrote in message
news:4546...@newsgroups.borland.com...

> Is it possible to detect current insert/overwrite mode in
> TRichEdit component?

Not directly, no. A RichEdit control does not report that information.

A RichEdit control is intially in insert mode when created. You would have
to manually track Insert button keystrokes being pressed. For example:

var
InsertMode: Boolean = True;

procedure TForm1.RichEdit1KeyDown(Sender: TObject; var Key: Word; Shift:
TShiftState);
begin
if (Key = VK_INSERT) and (Shift = []) then
begin
InsertMode := not InsertMode;
// update the status bar...
end;
end;


Gambit


Remko Bonte

unread,
Oct 31, 2006, 7:20:50 PM10/31/06
to
kurc66 wrote:
>
> Is it possible to detect current insert/overwrite mode in TRichEdit
> component?

I think this is possible using the TOM (Text Object Model) interfaces
like this:

uses
tom_TLB;

procedure TForm1.Button1Click(Sender: TObject);
var
RichEditOle: IUnknown;
TextDocument: ITextDocument;
begin
if SendMessage(RichEdit1.Handle, EM_GETOLEINTERFACE, 0,
Longint(@RichEditOle)) <> 0 then
begin
if Supports(RichEditOle, ITextDocument, TextDocument) then
begin
if TextDocument.Selection.Flags and tomSelOvertype =
tomSelOvertype then
ShowMessage('Overtype')
else
ShowMessage('Insert');
end;
end;
end;


--
Remko Bonte (Team JVCL) http://jvcl.sourceforge.net

Remy Lebeau (TeamB)

unread,
Oct 31, 2006, 7:29:35 PM10/31/06
to

"Remko Bonte" <remkob...@Mmyrealbox.com> wrote in message
news:4547e85e$1...@newsgroups.borland.com...

> I think this is possible using the TOM (Text Object Model)
> interfaces like this:

Keep in mind that TOM requires RichEdit v2.0 or higher, but TRichEdit uses
RichEdit v1.0 instead.


Gambit


Remko Bonte

unread,
Oct 31, 2006, 7:55:24 PM10/31/06
to
Remy Lebeau (TeamB) wrote:
> Keep in mind that TOM requires RichEdit v2.0 or higher, but TRichEdit uses
> RichEdit v1.0 instead.

Yes, but it should work on 2000, XP etc., because the Rich Edit 1.0
emulator apparently supports TOM.

0 new messages