home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / tpwinst / windemos.pak / GENERIC.PAS < prev    next >
Pascal/Delphi Source File  |  1991-05-21  |  3KB  |  114 lines

  1. {************************************************}
  2. {                                                }
  3. {   Turbo Pascal for Windows                     }
  4. {   Demo program                                 }
  5. {   Copyright (c) 1991 by Borland International  }
  6. {                                                }
  7. {************************************************}
  8.  
  9. { "Generic" Windows application written in Turbo Pascal }
  10.  
  11. program Generic;
  12.  
  13. {$R GENERIC}
  14.  
  15. uses WinTypes, WinProcs;
  16.  
  17. const
  18.   AppName = 'Generic';
  19.  
  20. const
  21.   idm_About = 100;
  22.  
  23. function About(Dialog: HWnd; Message, WParam: Word;
  24.   LParam: Longint): Bool; export;
  25. begin
  26.   About := True;
  27.   case Message of
  28.     wm_InitDialog:
  29.       Exit;
  30.     wm_Command:
  31.       if (WParam = id_Ok) or (WParam = id_Cancel) then
  32.       begin
  33.         EndDialog(Dialog, 1);
  34.         Exit;
  35.       end;
  36.   end;
  37.   About := False;
  38. end;
  39.  
  40. function WindowProc(Window: HWnd; Message, WParam: Word;
  41.   LParam: Longint): Longint; export;
  42. var
  43.   AboutProc: TFarProc;
  44. begin
  45.   WindowProc := 0;
  46.   case Message of
  47.     wm_Command:
  48.       if WParam = idm_About then
  49.       begin
  50.         AboutProc := MakeProcInstance(@About, HInstance);
  51.         DialogBox(HInstance, 'AboutBox', Window, AboutProc);
  52.         FreeProcInstance(AboutProc);
  53.         Exit;
  54.       end;
  55.     wm_Destroy:
  56.       begin
  57.         PostQuitMessage(0);
  58.         Exit;
  59.       end;
  60.   end;
  61.   WindowProc := DefWindowProc(Window, Message, WParam, LParam);
  62. end;
  63.  
  64. procedure WinMain;
  65. var
  66.   Window: HWnd;
  67.   Message: TMsg;
  68. const
  69.   WindowClass: TWndClass = (
  70.     style: 0;
  71.     lpfnWndProc: @WindowProc;
  72.     cbClsExtra: 0;
  73.     cbWndExtra: 0;
  74.     hInstance: 0;
  75.     hIcon: 0;
  76.     hCursor: 0;
  77.     hbrBackground: 0;
  78.     lpszMenuName: AppName;
  79.     lpszClassName: AppName);
  80. begin
  81.   if HPrevInst = 0 then
  82.   begin
  83.     WindowClass.hInstance := HInstance;
  84.     WindowClass.hIcon := LoadIcon(0, idi_Application);
  85.     WindowClass.hCursor := LoadCursor(0, idc_Arrow);
  86.     WindowClass.hbrBackground := GetStockObject(white_Brush);
  87.     if not RegisterClass(WindowClass) then Halt(255);
  88.   end;
  89.   Window := CreateWindow(
  90.     AppName,
  91.     'Turbo Pascal Generic',
  92.     ws_OverlappedWindow,
  93.     cw_UseDefault,
  94.     cw_UseDefault,
  95.     cw_UseDefault,
  96.     cw_UseDefault,
  97.     0,
  98.     0,
  99.     HInstance,
  100.     nil);
  101.   ShowWindow(Window, CmdShow);
  102.   UpdateWindow(Window);
  103.   while GetMessage(Message, 0, 0, 0) do
  104.   begin
  105.     TranslateMessage(Message);
  106.     DispatchMessage(Message);
  107.   end;
  108.   Halt(Message.wParam);
  109. end;
  110.  
  111. begin
  112.   WinMain;
  113. end.
  114.