unit QTMRichEdit;
interface
uses
SysUtils, Classes, Controls, StdCtrls, ComCtrls,Windows,Messages;
const
TMWM__SpecialInvalidate = WM_USER + 2222;
type
TTMRichEdit = class(TRichEdit)
private
{ Private declarations }
procedure SpecialInvalidate(var Message:TMessage);
message TMWM__SpecialInvalidate;
procedure WMHScroll(var Message: TWMHScroll);
message WM_HSCROLL;
procedure WMVScroll(var Message: TWMVScroll);
message WM_VSCROLL;
procedure WMSetText(var Message:TWMSetText);
message WM_SETTEXT;
procedure CNCTLCOLOREDIT(var Message:TWMCTLCOLOREDIT);
message CN_CTLCOLOREDIT;
procedure CNCTLCOLORMSGBOX(var Message:TWMCTLCOLORMSGBOX);
message CN_CTLCOLORMSGBOX;
procedure CNCTLCOLORSTATIC(var Message:TWMCTLCOLORSTATIC);
message CN_CTLCOLORSTATIC;
procedure WMKeyDown(var Message: TWMKeyDown);
message WM_KEYDOWN;
procedure WMEraseBkgnd(var Message: TWMEraseBkgnd);
message WM_ERASEBKGND;
procedure WMMove(var Message: TMessage);
message WM_MOVE;
procedure CMMouseEnter(var Message: TMessage);
message CM_MOUSEENTER;
procedure CMMouseLeave(var Message: TMessage);
message CM_MOUSELEAVE;
//procedure WMMouseMove (Var Message: TWMMouseMove);
Message WM_MouseMove;
procedure WMLButtonDown(Var Message: TWMLButtonDown);
Message WM_LButtonDown;
procedure WMKillFocus(Var Message: TWMKillFocus);
Message WM_KillFocus;
procedure WMMOUSEWHEELl(var Message:TMessage);message WM_MOUSEWHEEL;
protected
{ Protected declarations }
procedure CreateParams(var Params: TCreateParams);
override;
procedure CreateWnd;override;
public
{ Public declarations }
constructor Create(AOwner: TComponent);
override;
published
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Standard', [TTMRichEdit]);
end;
{ TTMRichEdit }
procedure TTMRichEdit.CMMouseEnter(var Message: TMessage);
begin
inherited;
if not (csDesigning in ComponentState) then
PostMessage(Handle,TMWM__SpecialInvalidate,0,0);
end;
procedure TTMRichEdit.CMMouseLeave(var Message: TMessage);
begin
inherited;
if not (csDesigning in ComponentState) then
PostMessage(Handle,TMWM__SpecialInvalidate,0,0);
end;
procedure TTMRichEdit.CNCTLCOLOREDIT(var Message: TWMCTLCOLOREDIT);
begin
with Messagedo
begin
SetBkMode(ChildDC,Windows.TRANSPARENT);
Result:=GetStockObject(HOLLOW_BRUSH)
//Result:=NullBrush;
end
end;
procedure TTMRichEdit.CNCTLCOLORMSGBOX(var Message: TWMCTLCOLORMSGBOX);
begin
Message.Result:=-1;
end;
procedure TTMRichEdit.CNCTLCOLORSTATIC(var Message: TWMCTLCOLORSTATIC);
begin
Message.Result:=-1;
end;
constructor TTMRichEdit.Create(AOwner: TComponent);
begin
inherited create(AOwner);;
//ControlStyle := [csCaptureMouse, csDesignInteractive, csClickEvents,
// csSetCaption, csOpaque, csDoubleClicks, csReplicatable, csNoStdEvents];
//FTransParent:=True;
end;
procedure TTMRichEdit.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
with Paramsdo
begin
ExStyle:=ExStyle or WS_EX_TRANSPARENT and not WS_EX_WINDOWEDGE
and not WS_EX_STATICEDGE and not WS_EX_DLGMODALFRAME and not WS_EX_CLIENTEDGE;
end;
end;
procedure TTMRichEdit.CreateWnd;
begin
inherited CreateWnd;
SetWindowLong(Parent.Handle, GWL_STYLE,
GetWindowLong(Parent.Handle, GWL_STYLE) and not WS_CLIPCHILDREN);
SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle,GWL_EXSTYLE) or WS_EX_TRANSPARENT);
end;
procedure TTMRichEdit.SpecialInvalidate(var Message: TMessage);
var r:TRect;
begin
if Parent<>nil then
begin
r:=ClientRect;
r.TopLeft:=Parent.ScreenToClient(ClientToScreen(r.TopLeft));
r.BottomRight:=Parent.ScreenToClient(ClientToScreen(r.BottomRight));
InvalidateRect(Parent.Handle,@r,true);
RedrawWindow(Handle,nil,0,RDW_FRAME+RDW_INVALIDATE)
end;
Message.Result:=1;
end;
procedure TTMRichEdit.WMEraseBkgnd(var Message: TWMEraseBkgnd);
begin
//Update;
Message.Result := 1;
end;
procedure TTMRichEdit.WMHScroll(var Message: TWMHScroll);
begin
inherited;
PostMessage(Handle,TMWM__SpecialInvalidate,0,0);
end;
procedure TTMRichEdit.WMKeyDown(var Message: TWMKeyDown);
begin
SendMessage(Handle,TMWM__SpecialInvalidate,0,0);
inherited;
PostMessage(Handle,TMWM__SpecialInvalidate,0,0);
end;
procedure TTMRichEdit.WMKillFocus(var Message: TWMKillFocus);
begin
inherited;
if not (csDesigning in ComponentState) then
PostMessage(Handle,TMWM__SpecialInvalidate,0,0)
end;
procedure TTMRichEdit.WMLButtonDown(var Message: TWMLButtonDown);
begin
inherited;
if not (csDesigning in ComponentState) then
PostMessage(Handle,TMWM__SpecialInvalidate,0,0);
end;
procedure TTMRichEdit.WMMOUSEWHEELl(var Message: TMessage);
begin
PostMessage(Handle,TMWM__SpecialInvalidate,0,0);
if Message.Result = 0 then
inherited;
PostMessage(Handle,TMWM__SpecialInvalidate,0,0);
Update;
end;
procedure TTMRichEdit.WMMove(var Message: TMessage);
begin
inherited;
SendMessage(Handle,TMWM__SpecialInvalidate,0,0);
end;
procedure TTMRichEdit.WMSetText(var Message: TWMSetText);
begin
inherited;
if not (csDesigning in ComponentState) then
PostMessage(Handle,TMWM__SpecialInvalidate,0,0)
end;
procedure TTMRichEdit.WMVScroll(var Message: TWMVScroll);
begin
SendMessage(Handle,TMWM__SpecialInvalidate,0,0);
inherited;
PostMessage(Handle,TMWM__SpecialInvalidate,0,0);
end;
end.