home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / pcmag / vol11n19.zip / TEST2.PAS < prev    next >
Pascal/Delphi Source File  |  1992-07-27  |  1KB  |  47 lines

  1. {
  2. Title:  TEST2.PAS
  3. Caption:This small program shows how little code is needed to invoke an Open File common dialog using the new TFileDlg object.
  4. }
  5.  
  6. program Test2;
  7.  
  8. uses winprocs, wintypes, wobjects, strings, commdlg, UTest2;
  9.  
  10. {$R Test2}
  11.  
  12. type
  13.  
  14.   TMyApp = object(TApplication)
  15.     procedure InitMainWindow; virtual;
  16.   end;
  17.  
  18.   PMyMainWindow = ^TMyMainWindow;
  19.   TMyMainWindow = object(TMDIWindow)
  20.     procedure cmFileOpen(var Msg: TMessage); virtual cm_First + 101;
  21.   end;
  22.  
  23. procedure TMyMainWindow.cmFileOpen(var Msg: TMessage);
  24. var
  25.   FileName: array [0..79] of Char;
  26.   Result: Integer;
  27. begin
  28.   StrCopy(FileName, '*.pas');
  29.   Result := Application^.ExecDialog(new(PFileDlg,
  30.         Init(@Self, OFN_FileMustExist, Filename, SizeOf(Filename))));
  31.   if Result = idOk then                     
  32.     MessageBox(HWindow, Filename, 'You selected', mb_OK);
  33. end;
  34.  
  35. procedure TMyApp.InitMainWindow;
  36. begin
  37.   MainWindow := new(PMyMainWindow, Init('Test CommDlg',
  38.                      LoadMenu(HInstance, 'MainMenu')));
  39. end;
  40.  
  41. var MyApp: TMyApp;
  42. begin
  43.   MyApp.Init('TestCommDlg');
  44.   MyApp.Run;
  45.   MyApp.Done;
  46. end.
  47.