home *** CD-ROM | disk | FTP | other *** search
/ Mega Top 1 / os2_top1.zip / os2_top1 / APPS / PROG / PASCAL / SPEED2 / SAMPLES / HALLO2 / HALLO2.PAS < prev    next >
Pascal/Delphi Source File  |  1994-10-11  |  4KB  |  230 lines

  1. PROGRAM Hallo2;
  2.  
  3. {***************************************************************************
  4. *                                                                          *
  5. *                Speed-Pascal/2 Sample program "Hallo2"                    *
  6. *                                                                          *
  7. *           (C) 1993,94 Rene Nürnberger. All rights reserved.              *
  8. *                                                                          *
  9. *                                                                          *
  10. *  This program extends the sample program "Hallo1" by a MenuBar           *
  11. *                                                                          *
  12. *                                                                          *
  13. ****************************************************************************}
  14.  
  15.  
  16. USES PmTypes,Crt,API;  {bind Units used}
  17.  
  18.  
  19. {Bind external resources}
  20. RESOURCE Hallo2;
  21.  
  22.  
  23. VAR
  24.     HalloClass:STRING; {Window-Class of the main window}
  25.     WindowStyle:ULONG; {Style of the main window}
  26.     Frame,Win:HWND;    {Handles of the main Window}
  27.     Title:STRING;      {Title of the main window}
  28.     _qmsg:QMSG;        {Message queue}
  29.  
  30.  
  31. {Dialog procedure for the Dialog "About". Handles messages.
  32.  Messages not processed will be given to the Standard Dialog-Procedure
  33.  (WinDefDlgProc).
  34.  This function must be CDECL because PM calls this in C-Manner}
  35. FUNCTION DlgWinProc(Dlg:HWND;Msg:ULONG;Para1,Para2:POINTER):ULONG;CDECL;
  36. VAR
  37.     result:ULONG;
  38. BEGIN
  39.      result:=WinDefDlgProc(Para2,Para1,Msg,Dlg);
  40.      DlgWinProc:=result;
  41. END;
  42.  
  43. {Window procedure for the Window-Class "Hallo". Handles messages.
  44.  Messages not processed will be given to the Standard Window-Procedure
  45.  (WinDefWndProc).
  46.  This function must be CDECL because PM calls this in C-Manner}
  47. FUNCTION WindowProc(Win:HWND;Msg:ULONG;Para1,Para2:POINTER):ULONG;CDECL;
  48. VAR Handled:BOOLEAN;
  49.     result:ULONG;
  50.     command:WORD;
  51.     Dlg:HWND;
  52. BEGIN
  53.      Handled:=TRUE;
  54.      result:=0;
  55.      CASE Msg OF
  56.          WM_ERASEBACKGROUND:result:=1;
  57.          WM_CLOSE:WinPostMsg(NIL,NIL,WM_QUIT,Win);
  58.          WM_COMMAND:
  59.          BEGIN
  60.               command:=WORD(para1);
  61.               CASE command OF
  62.                   CM_ABOUT:
  63.                   BEGIN
  64.                         Dlg:=WinLoadDlg(NIL,2000,0,@DlgWinProc,Frame,
  65.                                         HWND_DESKTOP);
  66.                         WinProcessDlg(Dlg);
  67.                         WinDestroyWindow(Dlg);
  68.                   END;
  69.                   ELSE Handled:=FALSE;
  70.               END; {case}
  71.          END;
  72.          ELSE Handled:=FALSE;
  73.      END; {Case}
  74.      IF not Handled THEN result:=WinDefWindowProc(Para2,Para1,Msg,Win);
  75.      WindowProc:=result;
  76. END;
  77.  
  78. BEGIN {Main}
  79.      {Initialize PM}
  80.      AppHandle:=WinInitialize(0);
  81.      AppQueueHandle:=WinCreateMsgQueue(0,AppHandle);
  82.  
  83.      {register Window class}
  84.      HalloClass:='Hallo';
  85.      WinRegisterClass(0,CS_SIZEREDRAW,@WindowProc,HalloClass,AppHandle);
  86.  
  87.      {ddefine main window}
  88.      WindowStyle:=FCF_TITLEBAR OR FCF_SYSMENU OR FCF_MINMAX OR FCF_TASKLIST
  89.                   OR FCF_SIZEBORDER OR FCF_ICON OR FCF_MENU;
  90.      Title:='Hallo2 Sample Application';
  91.      Frame:=WinCreateStdWindow(Win,1000,0,0,Title,HalloClass,WindowStyle,0,
  92.                                HWND_DESKTOP);
  93.  
  94.      {Set position and show main window}
  95.      WinSetWindowPos(SWP_SHOW OR SWP_ACTIVATE OR SWP_MOVE OR SWP_SIZE,
  96.                      200,300,100,100,HWND_TOP,Frame);
  97.  
  98.      {Handle message queue}
  99.      WHILE WinGetMsg(0,0,0,_qmsg,Apphandle)<>0 DO
  100.        WinDispatchMsg(_qmsg,Apphandle);
  101.  
  102.      {Destroy main window}
  103.      WinDestroyWindow(Frame);
  104.  
  105.      {Shut down PM}
  106.      WinDestroyMsgQueue(AppQueueHandle);
  107.      WinTerminate(AppHandle);
  108. END.
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.