Edit,Memo,Treeview加背景图片

来源:互联网 发布:mac版的eos utility 编辑:程序博客网 时间:2024/06/15 12:09

//本方法不够完善,比如滚动条还不能加载图片

 

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Image1: TImage;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations } 
    procedure HandleCTLColorEdit(var Msg: TWMCTLCOLOREDIT);
      message WM_CTLCOLOREDIT;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Memo1.Brush.Bitmap := Image1.Picture.Bitmap; // 这里背景图片取image1里的图片
  Memo1.Repaint;
end;

procedure TForm1.HandleCTLColorEdit(var Msg: TWMCTLCOLOREDIT);
begin
  inherited;

  if Msg.ChildWnd = Memo1.Handle then
  begin
    SetBkMode(Msg.ChildDC, TRANSPARENT);
    Msg.Result := Memo1.Brush.Handle;
  end;

end;

end.

 

 

// DFM

object Form1: TForm1
  Left = 215
  Top = 126
  Width = 390
  Height = 287
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  DesignSize = (
    382
    260)
  PixelsPerInch = 96
  TextHeight = 13
  object Image1: TImage
    Left = 216
    Top = 64
    Width = 105
    Height = 105
    Picture.Data = {
      07544269746D6170AE000000424DAE0000000000000036000000280000000100
      00001E000000010018000000000078000000C40E0000C40E0000000000000000
      00004FA2C500F2FCFF00C2F4FF00C3F4FF00C5F5FF00C7F5FF00C9F6FF00CBF6
      FF00CCF6FF00CEF7FF00D0F7FF00D1F8FF00D3F8FF00D5F8FF00D6F9FF00D8F9
      FF00DAFAFF00DBFAFF00DDFAFF00DEFBFF00DFFBFF00E1FBFF00E2FCFF00E3FC
      FF00E4FCFF00E5FCFF00E6FDFF00E7FDFF00FAFFFF004FA2C500}
  end
  object Memo1: TMemo
    Left = 32
    Top = 24
    Width = 313
    Height = 193
    Anchors = [akLeft, akTop, akRight, akBottom]
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -24
    Font.Name = 'MS Sans Serif'
    Font.Style = []
    Lines.Strings = (
      'Memo1')
    ParentFont = False
    ScrollBars = ssBoth
    TabOrder = 0
    OnChange = Memo1Change
  end
end