想要使TMemo,TPageControl组件做成透明,使得该组件上显示的内容,可以透明的显示在组件下面的图片上.
高手执教,Thanks!

解决方案 »

  1.   

    unit TransMemoUnit;interface//thanx to Clinton R. Johnsonuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls;type
      TTransMemo = class(TMemo)
      private
        { Private declarations }
        FBitmap : TBitmap;
      protected
        { Protected declarations }
        Constructor Create (AnOwner : TComponent); overRide;
        Destructor Destroy; Override;    Procedure DefaultHandler (Var Message); Override;
        Procedure WM_EraseBkGnd(Var Msg : TWMEraseBkGnd); Message WM_EraseBkGnd;
        Procedure SetBitmap(NewBitmap : TBitmap);
      public
        { Public declarations }
      published
        { Published declarations }
        Property Bitmap : TBitmap Read fBitmap Write SetBitmap;
      end;procedure Register;implementationConstructor TTransMemo.Create (AnOwner : TComponent);Begin
      Inherited Create(AnOwner);
      FBitmap := TBitmap.Create;
      Color := clNone;  // Setting to clWindow causes the strange behavior we are all familiar with.
    End;Destructor TTransMemo.Destroy;Begin
      fBitmap.Free;
      Inherited Destroy;
    End;Procedure TTransMemo.SetBitmap(NewBitmap : TBitmap);Begin
      FBitmap.Assign(NewBitmap);
    End;// The only real place to tie into the VCL for
    // tranparnent fonts...Procedure TTransMemo.DefaultHandler (Var Message);Begin
      Inherited DefaultHandler(Message);
      With TMessage(Message) Do
      Begin
        Case Msg Of
          cn_CTLCOLORMSGBOX..cn_CTLCOLORSTATIC:
            begin
              SetBkMode(WParam, Transparent);
            end;
        End;
      End;
    End;Procedure TTransMemo.WM_EraseBkGnd(Var Msg : TWMEraseBkGnd);Var
      Canvas : TCanvas;Begin
      Inherited;
    // Draw your own custom background here.
      Canvas := TCanvas.Create;
      Canvas.Handle := msg.DC;
      Canvas.Draw(0,0,fBitmap);
      Canvas.Free;
    End;procedure Register;
    begin
      RegisterComponents('Samples', [TTransMemo]);
    end;end.
      

  2.   

    同時請參考這裡:
    http://topic.csdn.net/t/20041210/19/3634904.html
      

  3.   

    呵呵 自己画一个,用Image加载,然后放的 Label控件 就可以了啊 呵呵...有难度哦
      

  4.   

    感觉金山那个是假透明。
    先把需要显示遮挡的区域抓个图,然后进行alpha处理,然后作为自己窗口背景,看上去,窗口就透明到桌面上了。
      

  5.   

    我现在能够控件透明了,近似的功能能实现了,存在问题:
        1,该透明控件获得焦点时,变得不透明了,需屏蔽获得焦点;
        2,最大得问题是,当该控件ReadOnly=true时,就变得不透明了,不知道为什么?
        楼上,你那个alpha处理,是什么意思啊,我不懂,高手讲讲吧^_^?
      

  6.   

    我现在能够控件透明了,近似的功能能实现了,存在问题:
        1,该透明控件获得焦点时,变得不透明了,需屏蔽获得焦点;
        2,最大得问题是,当该控件ReadOnly=true时,就变得不透明了,不知道为什么?
        楼上,你那个alpha处理,是什么意思啊,我不懂,高手讲讲吧^_^?
    =============================================
    你才paint消息中也加入透明处理代码看看?
    或者在获得焦点的时候也处理一下透明!