I need to disable both mouse buttons on the event OnMouseEnter of a TRichEdit component and enable again on the event OnMouseLeave.
Setting the TRichEdit enabled = false does not solve my problem.
Any tips ?
I need to disable both mouse buttons on the event OnMouseEnter of a TRichEdit component and enable again on the event OnMouseLeave.
Setting the TRichEdit enabled = false does not solve my problem.
Any tips ?
You can subclass your rich edit so that to intercept mouse button down/up messages. Then you don't need to watch for the mouse entering, leaving the control. Example:
type
TForm1 = class(TForm)
...
private
FSaveRichEditProc: TWndMethod;
procedure RichEditWindowProc(var Message: TMessage);
..
end;
...
procedure TForm1.FormCreate(Sender: TObject);
begin
FSaveRichEditProc := RichEdit1.WindowProc;
RichEdit1.WindowProc := RichEditWindowProc;
end;
procedure TForm1.RichEditWindowProc(var Message: TMessage);
begin
case Message.Msg of
WM_LBUTTONDOWN, WM_LBUTTONUP, WM_LBUTTONDBLCLK,
WM_MBUTTONDOWN, WM_MBUTTONUP, WM_MBUTTONDBLCLK,
WM_RBUTTONDOWN, WM_RBUTTONUP, WM_RBUTTONDBLCLK:
begin
Message.Result := 0;
Exit;
end;
end;
FSaveRichEditProc(Message);
end;