home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l040 / 11.ddi / WDOCDEMO.ZIP / STEP01C.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-10-27  |  1.6 KB  |  62 lines

  1. {************************************************}
  2. {                                                }
  3. {   ObjectWindows Demo                           }
  4. {   Copyright (c) 1992 by Borland International  }
  5. {                                                }
  6. {************************************************}
  7.  
  8. program Step01c;
  9.  
  10. uses WinTypes, WinProcs, OWindows;
  11.  
  12. type
  13.   PStepWindow = ^TStepWIndow;
  14.   TStepWindow = object(TWindow)
  15.     HasChanged: Boolean;
  16.     constructor Init(AParent: PWindowsObject; ATitle: PChar);
  17.     function CanClose: Boolean; virtual;
  18.     procedure WMLButtonDown(var Msg: TMessage);
  19.       virtual wm_First + wm_LButtonDown;
  20.   end;
  21.   TMyApplication = object(TApplication)
  22.     procedure InitMainWindow; virtual;
  23.   end;
  24.  
  25. constructor TStepWindow.Init(AParent: PWindowsObject; ATitle: PChar);
  26. begin
  27.   inherited Init(AParent, ATitle);
  28.   HasChanged := False;
  29. end;
  30.  
  31. function TStepWindow.CanClose: Boolean;
  32. var
  33.   Reply: Integer;
  34. begin
  35.   CanClose := True;
  36.   if HasChanged then
  37.   begin
  38.     Reply := MessageBox(HWindow, 'Do you want to save?',
  39.       'Drawing has changed', mb_YesNo or mb_IconQuestion);
  40.     if Reply = id_Yes then CanClose := False;
  41.   end;
  42. end;
  43.  
  44. procedure TStepWindow.WMLButtonDown(var Msg: TMessage);
  45. begin
  46.   MessageBox(HWindow, 'You have pressed the left mouse button',
  47.   'Message Dispatched', mb_OK);
  48. end;
  49.  
  50. procedure TMyApplication.InitMainWindow;
  51. begin
  52.   MainWindow := New(PStepWindow, Init(nil, 'Steps'));
  53. end;
  54.  
  55. var
  56.   MyApp: TMyApplication;
  57.  
  58. begin
  59.   MyApp.Init('Steps');
  60.   MyApp.Run;
  61.   MyApp.Done;
  62. end.