ShowAutoTrimDlg example for Delphi

procedure TForm1.ShowAutoTrimDlg1Click(Sender: TObject); 
var
   nRet: L_INT; 
begin
   LEADDlgImage1.DlgFlags:= DLG_AUTOTRIM_AUTOPROCESS Or
                             DLG_AUTOTRIM_SHOW_PREVIEW; 

   LEADDlgImage1.LEADImage:= LEADImage1; 
   LEADDlgImage1.LEADDlgService:= LEADDlgService1; 
   nRet:= LEADDlgImage1.ShowAutoTrimDlg ( Self ); 
   if ( nRet = SUCCESS_DLG_OK ) then
   begin
      LEADImage1.AutoTrim ( LEADDlgImage1.Threshold ); 
   end; 
end;