home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / wksinst / rwpdemo.pak / BITBNAPP.PAS next >
Pascal/Delphi Source File  |  1991-09-09  |  2KB  |  109 lines

  1. {************************************************}
  2. {                                                }
  3. {   Turbo Pascal for Windows                     }
  4. {   Demo program                                 }
  5. {   Copyright (c) 1991 by Borland International  }
  6. {                                                }
  7. {************************************************}
  8.  
  9. { This program uses a DLL that implements custom controls.
  10.   Make sure you build the DLL (BITBTN.PAS) before running
  11.   this program. }
  12.  
  13. program BitBnApp;
  14.  
  15. {$R BitBnApp.RES}
  16.  
  17. uses WinTypes, WinProcs, WObjects;
  18.  
  19. const
  20.   DLLName = 'BITBTN.DLL';
  21.  
  22. const
  23.   em_DLLNotFound = 1;
  24.  
  25. type
  26.   PBitWindow = ^TBitWindow;
  27.   TBitWindow = object(TDlgWindow)
  28.     procedure Yes(var Msg: TMessage);
  29.       virtual id_First + id_Yes;
  30.     procedure No(var Msg: TMessage);
  31.       virtual id_First + id_No;
  32.     procedure Ok(var Msg: TMessage);
  33.       virtual id_First + id_OK;
  34.     procedure Cancel(var Msg: TMessage);
  35.       virtual id_First + id_Cancel;
  36.   end;
  37.  
  38.   PBitApp = ^TBitApp;
  39.   TBitApp = object(TApplication)
  40.     Lib: THandle;
  41.     constructor Init(AName: PChar);
  42.     destructor Done; virtual;
  43.     procedure InitMainWindow; virtual;
  44.     procedure Error(ErrorCode: Integer); virtual;
  45.   end;
  46.  
  47. { TBitApp }
  48.  
  49. constructor TBitApp.Init(AName: PChar);
  50. begin
  51.   Lib := LoadLibrary(DLLName);
  52.   if Lib < 32 then Status := em_DLLNotFound;
  53.   TApplication.Init(AName);
  54. end;
  55.  
  56. destructor TBitApp.Done;
  57. begin
  58.   TApplication.Done;
  59.   FreeLibrary(Lib);
  60. end;
  61.  
  62. procedure TBitApp.InitMainWindow;
  63. begin
  64.   MainWindow := New(PBitWindow, Init(nil, MakeIntResource(100)));
  65. end;
  66.  
  67. procedure TBitApp.Error(ErrorCode: Integer);
  68. begin
  69.   case ErrorCode of
  70.     em_DLLNotFound:
  71.       MessageBox(0, DLLName + ' not found. Please compile BITBTN.PAS ' +
  72.         'before executing this application.', 'Fatal error',
  73.         mb_Ok or mb_IconStop);
  74.   else
  75.     TApplication.Error(ErrorCode);
  76.   end;
  77. end;
  78.  
  79. { TBitWindow }
  80.  
  81. procedure TBitWindow.Yes(var Msg: TMessage);
  82. begin
  83.   CloseWindow;
  84. end;
  85.  
  86. procedure TBitWindow.No(var Msg: TMessage);
  87. begin
  88.   CloseWindow;
  89. end;
  90.  
  91. procedure TBitWindow.Ok(var Msg: TMessage);
  92. begin
  93.   CloseWindow;
  94. end;
  95.  
  96. procedure TBitWindow.Cancel(var Msg: TMessage);
  97. begin
  98.   CloseWindow;
  99. end;
  100.  
  101. var
  102.   App: TBitApp;
  103.  
  104. begin
  105.   App.Init('TBITBTN.DDL Demo');
  106.   App.Run;
  107.   App.Done;
  108. end.
  109.