Thanks,
Roman Kurcjusz
> 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
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
> 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
Yes, but it should work on 2000, XP etc., because the Rich Edit 1.0
emulator apparently supports TOM.