unit mainform;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ActnList, Menus, ExtCtrls, ComCtrls, ImgList, ToolWin, FileCtrl,
  StdCtrls, ExtDlgs,SlideSetForm,ShellAPI,Jpeg;type
  TViewForm = class(TForm)
    Open1: TAction;
    SaveAs1: TAction;
    Cut1: TAction;
    Print1: TAction;
    .
    .
    .
    Label2: TLabel;
    DirectoryListBox1: TDirectoryListBox;
    Splitter1: TSplitter;
    PopupMenu1: TPopupMenu;
        N33: TMenuItem;
    X3: TMenuItem;
    OPD: TOpenDialog;
    SavePic: TSavePictureDialog;
    PrintDialog1: TPrintDialog;
    PrinterSetupDialog1: TPrinterSetupDialog;
    Timer1: TTimer;
    Splitter2: TSplitter;
    procedure FormCreate(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
    procedure Exit1Execute(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure Splitter2Moved(Sender: TObject);
    procedure Open1Execute(Sender: TObject);
  private
  procedure DoLoad(const FileName: String);
    { Private declarations }
  public
    { Public declarations }
  end;
  Function GetImgList(Sender:TObject):Boolean;  var
  ViewForm: TViewForm;
  tmpBitmap:Tbitmap;
  iBitmapValide:Boolean;
  FileExt:string[4];
  JPEGImage:TJPEGImage;
  WinWidth,WinHeight,WinLeft,WinTop:Integer;//窗口大小位置
  FileIndex:Integer;
  FileNum:Integer;
  Circulation:Boolean;
  //用于图片漫游
  Origin:Tpoint;
  ImageLeft:integer;
  ImageTop:Integer;
  Visa1:Tpoint;
  VIsa2:Tpoint;
  Canmove:boolean;
  hm:HMENU;implementationprocedure TViewForm.Open1Execute(Sender: TObject);
begin
  if OPD.Execute then
    begin
      Doload(OPD.FileName);
      StatusBar1.Panels[1].Text:=OPD.FileName;
      GetImgList(Sender);
    end;
end;上面代码中函数Function GetImgList(Sender:TObject):Boolean;怎么可以在那里定义,在别人的程序里可以通过编译,在我的程序里就不行呢?

解决方案 »

  1.   

    Function GetImgList(Sender:TObject):Boolean;
     定义在那里是普通的全局函数阿
    你报的什么错呢?
      

  2.   

    [Warning] mainform.pas(7): Unit 'FileCtrl' is specific to a platform
    [Error] mainform.pas(160): Unsatisfied forward or external declaration: 'GetImgList'
    [Fatal Error] Graphishow.dpr(6): Could not compile used unit 'mainform.pas'
      

  3.   

    type
      TViewForm = class(TForm)
       {...}
      public
        Function GetImgList(Sender:TObject):Boolean; //注意位置
        { Public declarations }
      end;
     
    implementationprocedure TViewForm.Open1Execute(Sender: TObject);
    begin
      {...}
    end;説明:你的函数定义要放在TViewForm定义中.
      

  4.   

    Function GetImgList(Sender:TObject):Boolean;//实现时不要在函数前加TViewForm.
    begin
      Result := True;
    end;