TMemo
虽然可以显示文本,倒入文本
但如何让他背景透明呀?

解决方案 »

  1.   

    johnsonrao能帮忙试一下
    并给出具体点的代码嘛?
    拜托了!
      

  2.   

    用透明的控件呗. 一般继承自TGraphicControl的
    (就是那些没有handle属性, 不能有focus的控件, 如image)
    都有Transparent属性. 对TWinControl类的控件, 要实现透明只要完成以下
    四步基本上就成了.
    1.在Create中设定ControlStyle :=
    ControlStyle - [csOpaque];)
    2. override 它的CreateParams方法, exstyle 里加上WS_EX_TRANSPARENT.
    3. 修改它的parent的window style, 去掉WS_CLIPCHILDREN.  inherited CreateParams(Params);
      with Params do
      begin
      { 完全重画 }
        Style := Style and not WS_CLIPCHILDREN;
        Style := Style and not WS_CLIPSIBLINGS;
      { 增加透明 }
        ExStyle := ExStyle or WS_EX_TRANSPARENT;
      end;
    4. 截获WM_ERASEBKGND, 什么都不做直接返回1.(不搽除背景)
    一般有上面3步能成. 有些控件比如TPanel, 在它的paint中用了fillrect, 所以要实现透明的话还要override 它的paint方法, 自己画.
    按钮透明需要进一步处理. 
    createparams里加上style := style or BS_OWNERDRAW;
    然后在WM_DRAWITEM中自己画吧
      

  3.   

    我已经自己搞定了,谢谢大家
    unit MySpeedButton;interfaceuses
      Windows, Messages, SysUtils, Classes, Controls, Buttons;type
      TMySpeedButton = class(TspeedButton)
      protected
        procedure CMMouseLeave(var Message: TMessage);message CM_MOUSELEAVE;
      end;procedure Register;implementationprocedure Register;
    begin
      RegisterComponents('ActiveX', [TMySpeedButton]);
    end;{ TMySpeedButton }
    procedure TMySpeedButton.CMMouseLeave(var Message: TMessage);
    var
      Rect:TRect;
    begin
      if (Visible) and (Parent <> nil) and Parent.HandleAllocated then
      begin
        Rect := BoundsRect;
        InvalidateRect(Parent.Handle, @Rect,True);
      end;
    end;end.