对事件‘赋值’的例子:

type   
 TSEvent=procedure (StatusBar: TStatusBar;Panel: TStatusPanel;
const Rect: TRect) of Object;
………
 private
SEvent:TSEvent;
    procedure mySDrawPanel(StatusBar: TStatusBar;Panel: TStatusPanel;
const Rect: TRect);
end;
procedure TFrm_Main.actLYJHExecute(Sender: TObject);
begin
....    SEvent:=mySDrawPanel;//见下面的注解 
   
  
    Form1.ShowModal;
    Form1.StatusBar1.OnDrawPanel:=SEvent;
  finally
...
 
  end;
end;
//自定义的处理过程
procedure TFrm_Main.mySDrawPanel(StatusBar: TStatusBar;Panel: TStatusPanel;const Rect: TRect);
begin
  StatusBar.Canvas.Brush.Color:=$00737157;
  StatusBar.Canvas.Font.Color:=$00EAEEEE;
  StatusBar.Canvas.FillRect(Rect);
  StatusBar.Canvas.TextRect(Rect,Rect.Left,Rect.Top,Panel.Text);
end;

注解:值得注意的是:如果是在一个Unit中,这样是不行的。

type TFormClose = procedure (Sender: TObject; var Action: TCloseAction) of Object;
....
procedure ShowForm(SchoolName:string;ParentHandle:HWND;frm:TForm);
var
   profrmClose : TFormClose ;
begin  TMethod(profrmClose).Code := @FormClose;
      TMethod(profrmClose).Data := nil;
  //-------说明:如果是在一个form单元中,不需要如此,直接proFrmClose := FormClose 就可以。具体原理还有待研究。  {frm.psSchoolName := pSchoolName;//学校名称
  frm.phMainHandle := h; //窗体句柄}
  psSchoolName := SchoolName;//学校名称
  phMainHandle := ParentHandle; //窗体句柄
  setParent(frm.handle,phMainHandle);
  frm.windowstate:=wsMaximized;
  HideTitle(frm);
  frm.Visible := true;
  frm.OnClose := profrmClose;
end;

//退出窗体
procedure FormClose(Sender: TObject; var Action: TCloseAction);
begin
     if(Application.Messagebox('真的要退出本程序?','询问提示',MB_YESNO+MB_DEFBUTTON2+MB_ICONQUESTION)=IDNo) then
     begin
          abort;
     end
     else
     begin
          ptr^:= LongInt(ptrMain);    //add
                   //主程序窗体尺寸还原add
         postmessage(phMainHandle,WM_SYSCOMMAND,SC_RESTORE,333);
     end;
end;