不要加其他控件,
请教,谢谢。
今晚就结贴。

解决方案 »

  1.   

    有点难度!Panel又没有canvas属性,怎么直接画图呢!
      

  2.   

    unit CustomPanel1;interfaceuses
      SysUtils, Classes, Controls,Graphics, ExtCtrls;type
      TCustomPanel1 = class(TCustomPanel)
      private
        { Private declarations }
        FGlpy:TBitmap;
        FGlyph: TBitmap;
        procedure SetGlyph(val:TBitmap);
      protected
        { Protected declarations }
        procedure paint;override;  public
        { Public declarations }
        constructor Create(AOwner:TComponent);override;
        destructor Destroy;override;
      published
        { Published declarations }
       property Glyph:TBitmap read  FGlyph write SetGlyph;
      end;procedure Register;implementationprocedure Register;
    begin
      RegisterComponents('HQJVCL', [TCustomPanel1]);
    end;{ TCustomPanel1 }constructor TCustomPanel1.Create(AOwner: TComponent);
    begin
      inherited Create(AOwner);
       FGlyph:=TBitmap.create;
       SetBounds(0,0,100,100);
    end;destructor TCustomPanel1.Destroy;
    begin
       FGlyph.free;
      inherited;
    end;procedure TCustomPanel1.paint;
    begin
      if not FGlyph.Empty then
      begin
      Canvas.Draw(0,0,FGlyph);
        //
      end
      else inherited;end;procedure TCustomPanel1.SetGlyph(val: TBitmap);
    begin
      FGlyph.Assign(val);
      invalidate;
    end;end.
      

  3.   

    在panel上加一个Image 控件,把它们的大小设成一样,加入图片就OK了,结贴给分吧,哈
      

  4.   

    这样多简单,那用象 SydPink(希望不再敲键盘!) 这样麻烦
      

  5.   

    对了,最后别忘了把Image的Align属性设为alClient
      

  6.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      aCanvas: TCanvas;
    begin
      aCanvas := TCanvas.Create;
      aCanvas.Handle := GetDC(Panel1.Handle);
      aCanvas.Draw(0, 0, Image1.Picture.Graphic);
      aCanvas.Free;
    end;