过程如下:Procedure (..)
var
  FindObject: TObject;
  DirNames, FileNames: TStringList;
begin
.
.
        FindObject:=FindComponent('img'+Copy(FileNames.Strings[j], 1, Pos('.',FileNames.Strings[j])-1));
        if FindObject is TImage then
        begin
       //   if NbkModal.Controls.VCLComObject=TImage. then
     //     begin
            FindObject:= TImage.Create(Self);
            with FindObject do
            begin
              Width:= bmpBase.Width;
              Height:= bmpBase.Height;
//             PanitBmp(TImage.Create(FindObject), bmpBase);
              Canvas.Draw(0,0, bmpBase);
            end;
          end;
     //   end;
//      end;      bmpBase.Free;
    end;
      SrcFileName:= Appdir+'\images\Bmp\channel_Plan\LayoutBase.Bmp';
      bmpBase:= TBitmap.Create;
      stmSrcFile := TFileStream.Create(SrcFileName,fmopenread);      bmpBase.LoadFromStream(stmSrcFile);
      stmSrcFile.Free;
            with imgChannelOptimize do
            begin
              Width:= bmpBase.Width;
              Height:= bmpBase.Height;
              Canvas.Draw(0,0, bmpBase);
            end;
      bmpBase.Free;
end;

解决方案 »

  1.   

    当然不行的了,FindObject是TObject
    FindObject:= TImage.Create(Self);with FindObject do 就会有问题
    改为with FindObject as TImage do
    不用as(类型转换)是不行的,
      

  2.   

    其中,
    可以画出图形(Bmp)的语句:SrcFileName:= Appdir+'\images\Bmp\channel_Plan\LayoutBase.Bmp';
          bmpBase:= TBitmap.Create;
          stmSrcFile := TFileStream.Create(SrcFileName,fmopenread);      bmpBase.LoadFromStream(stmSrcFile);
          stmSrcFile.Free;
                with imgChannelOptimize do
                begin
                  Width:= bmpBase.Width;
                  Height:= bmpBase.Height;
                  Canvas.Draw(0,0, bmpBase);
                end;
          bmpBase.Free;
    画不出图形(Bmp)的语句:      FilePath:= Appdir+'\images\Bmp\'+DirNames.Strings[i]+'\'+FileNames.Strings[j];
          SrcFileName:= FilePath;
          bmpBase:= TBitmap.Create;
          stmSrcFile := TFileStream.Create(SrcFileName,fmopenread);      bmpBase.LoadFromStream(stmSrcFile);
          stmSrcFile.Free;      FindObject:=FindComponent('img'+Copy(FileNames.Strings[j], 1, Pos('.',FileNames.Strings[j])-1));
          if FindObject is TImage then
          begin
            with FindObject do
            begin
              Width:= bmpBase.Width;
              Height:= bmpBase.Height;
              Canvas.Draw(0,0, bmpBase);
            end;
          end;      bmpBase.Free;
      

  3.   

    嘻嘻!..谢谢ly_liuyang(Liu Yang) 哟,你说的完全正确!:)
      

  4.   

    可以Draw的话,要从TWinControl继承下来的才可以吧。