home *** CD-ROM | disk | FTP | other *** search
/ Chip 1999 January / Chip_1999-01_cd.bin / zkuste / delphi / D4 / COOLFORM.ZIP / TrMemo.pas < prev    next >
Pascal/Delphi Source File  |  1998-05-12  |  3KB  |  101 lines

  1. unit TrMemo;
  2. {$R-}
  3. interface
  4. uses Messages, Controls, StdCtrls,classes;
  5. const TMWM__SpecialInvalidate=WM_USER+1111;
  6. type
  7.   TTransparentMemo = class(TMemo)
  8.   private
  9.     procedure SpecialInvalidate(var Message:TMessage); message
  10. TMWM__SpecialInvalidate;
  11.     procedure WMHScroll(var Message: TWMHScroll); message WM_HSCROLL;
  12.     procedure WMVScroll(var Message: TWMVScroll); message WM_VSCROLL;
  13.     procedure WMSetText(var Message:TWMSetText); message WM_SETTEXT;
  14.     procedure CNCTLCOLOREDIT(var Message:TWMCTLCOLOREDIT); message
  15. CN_CTLCOLOREDIT;
  16.     procedure WMKeyDown(var Message: TWMKeyDown); message WM_KEYDOWN;
  17.     procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ERASEBKGND;
  18.   protected
  19.     procedure CreateParams(var Params: TCreateParams); override;
  20.   public
  21. constructor Create(AOwner: TComponent); override;
  22.   end;
  23. procedure Register;
  24. implementation
  25. uses Windows;
  26. { TTransparentMemo }
  27. procedure TTransparentMemo.WMHScroll(var Message: TWMHScroll);
  28. begin
  29.   inherited;
  30.   PostMessage(Handle,TMWM__SpecialInvalidate,0,0);
  31. end;
  32. procedure TTransparentMemo.WMVScroll(var Message: TWMVScroll);
  33. begin
  34.   SendMessage(Handle,TMWM__SpecialInvalidate,0,0);
  35.   inherited;
  36.   PostMessage(Handle,TMWM__SpecialInvalidate,0,0);
  37. end;
  38. procedure TTransparentMemo.CNCTLCOLOREDIT(var Message:TWMCTLCOLOREDIT);
  39. begin
  40.   with Message do
  41.     begin
  42.       SetBkMode(ChildDC,TRANSPARENT);
  43.       Result:=GetStockObject(HOLLOW_BRUSH)
  44.     end
  45. end;
  46. procedure TTransparentMemo.WMSetText(var Message:TWMSetText);
  47. begin
  48.   inherited;
  49.   if not (csDesigning in ComponentState) then
  50.     PostMessage(Handle,TMWM__SpecialInvalidate,0,0)
  51. end;
  52. procedure TTransparentMemo.SpecialInvalidate(var Message:TMessage);
  53. var r:TRect;
  54. begin
  55.   if Parent<>nil then
  56.     begin
  57.       r:=ClientRect;
  58.       r.TopLeft:=Parent.ScreenToClient(ClientToScreen(r.TopLeft));
  59.       r.BottomRight:=Parent.ScreenToClient(ClientToScreen(r.BottomRight));
  60.       InvalidateRect(Parent.Handle,@r,true);
  61.       RedrawWindow(Handle,nil,0,RDW_FRAME+RDW_INVALIDATE)
  62.     end;
  63. end;
  64. procedure TTransparentMemo.WMKeyDown(var Message: TWMKeyDown);
  65. begin
  66.   SendMessage(Handle,TMWM__SpecialInvalidate,0,0);
  67.   inherited;
  68.   PostMessage(Handle,TMWM__SpecialInvalidate,0,0);
  69. end;
  70. procedure TTransparentMemo.WMEraseBkgnd(var Message: TWMEraseBkgnd);
  71. begin
  72.   Message.Result:=1
  73. end;
  74.  
  75. constructor TTransparentMemo.Create(AOwner: TComponent);
  76. begin
  77. inherited;
  78. ControlStyle:=[csCaptureMouse, csDesignInteractive,
  79. csClickEvents,  csSetCaption, csOpaque, csDoubleClicks,
  80.   csReplicatable, csNoStdEvents];
  81. end;
  82.  
  83. procedure TTransparentMemo.CreateParams(var Params: TCreateParams);
  84. begin
  85.   inherited CreateParams(Params);
  86.   with Params do
  87.   begin
  88.       ExStyle:=ExStyle or WS_EX_TRANSPARENT and not WS_EX_WINDOWEDGE
  89.              and not WS_EX_STATICEDGE and not WS_EX_DLGMODALFRAME and not
  90.            WS_EX_CLIENTEDGE;
  91.   end;
  92. end;
  93. procedure Register;
  94. begin
  95.   RegisterComponents('cool!', [tTransparentMemo]);
  96. end;
  97. end.
  98.  
  99.  
  100.  
  101.