home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / PM-M2B.ZIP / CLICK.MOD < prev    next >
Text File  |  1990-10-04  |  6KB  |  143 lines

  1. (*----------------------------------------------------------------------------*)
  2. (* Example OS/2 Presentation Manager Program adapted from the book            *)
  3. (* "OS/2 Presentation Manager - Programming Primer" by Asael Dror &           *)
  4. (* Robert Lafore                                                              *)
  5. (*                                                                            *)
  6. (* Example programs converted to JPI Modula-2 Version 2 for OS/2 1.2 by       *)
  7. (* Chris Barker, October 1990                                                 *)
  8. (*                                                                            *)
  9. (* Notes:  I am distributing these programs so that others can learn and also *)
  10. (*         so I can elicit feedback from the user community on programming for*)
  11. (*         OS/2 PM using Modula-2.  If your have any questions, suggestions,  *)
  12. (*         or comments I'd love to hear from you.  I may be reached at the    *)
  13. (*         following addresses:                                               *)
  14. (*                                                                            *)
  15. (*         Compuserve ID: 72261,2312                                          *)
  16. (*         Pete Norloff's OS/2 Shareware BBS - (703) 385-4325                 *)
  17. (*         Max's Doghouse BBS - (703) 548-7849                                *)
  18. (*           The above two BBS carry the Fidonet OS/2 echo which I read       *)
  19. (*           regularly.                                                       *)
  20. (*         Programmer's Corner - (301) 596-1180                               *)
  21. (*         CPCUG Mix (Window Sig) BBS - (301) 738-9060                        *)
  22. (*                                                                            *)
  23. (*         I hope I hear from you!                                            *)
  24. (*                                                                            *)
  25. (*               - Chris                                                      *)
  26. (*                                                                            *)
  27. (*----------------------------------------------------------------------------*)
  28.  
  29. (*----------------------------------------------------------------------------*)
  30. (*  Program Notes:                                                            *)
  31. (*    Whenever you press the left mouse button while inside the client window *)
  32. (*    you will hear a beep.                                                   *)
  33. (*    Source code on page 81.                                                 *)
  34. (*                                                                            *)
  35. (*----------------------------------------------------------------------------*)
  36.  
  37. (*# call(same_ds => off) *)
  38. (*# data(heap_size=> 3000) *)
  39.  
  40. MODULE CLICK;
  41.  
  42. IMPORT OS2DEF,Win,Gpi,Dos,Lib,SYSTEM,IO;
  43. FROM OS2DEF IMPORT HDC,HRGN,HAB,HPS,HBITMAP,HWND,HMODULE,HSEM,
  44.                    POINTL,RECTL,PID,TID,LSET,NULL,
  45.                    COLOR,NullVar,NullStr,BOOL ;
  46. FROM OS2MAC IMPORT SHORT1FROMMP,SHORT2FROMMP,MPFROMSHORT,MPFROM2SHORT;
  47.  
  48. TYPE
  49.   StrPtr = POINTER TO ARRAY[0..0] OF CHAR;
  50.  
  51. CONST
  52.   szClientClass = 'Client Window';
  53.  
  54. VAR
  55.   hab           : HAB;
  56.   hmq           : Win.HMQ;
  57.   qmsg          : Win.QMSG;
  58.   hwndClient,
  59.   client,
  60.   hwnd          : HWND;
  61.   r             : Win.MRESULT;
  62.   flcreateFlags : LSET;
  63.  
  64. PROCEDURE Error;
  65. BEGIN
  66. END Error;
  67.  
  68. (*--------------------  Start of window procedure  ---------------------*)
  69. (*# save,call(near_call=>off,reg_param=>(),reg_saved=>(di,si,ds,es,st1,st2)) *)
  70.  
  71. PROCEDURE ClientWinProc(
  72.                        hwnd : HWND;
  73.                        msg:CARDINAL;
  74.                        mp1,mp2:Win.MPARAM)
  75.                        : Win.MRESULT;
  76.  
  77. BEGIN
  78.   CASE msg OF
  79.     | Win.WM_BUTTON1DOWN : Win.Alarm(Win.HWND_DESKTOP,Win.WA_NOTE);
  80.                            RETURN Win.MPARAM(TRUE);
  81.     | Win.WM_ERASEBACKGROUND : RETURN Win.MPARAM(TRUE)
  82.   ELSE
  83.     RETURN Win.DefWindowProc(hwnd, msg, mp1, mp2)
  84.   END;
  85.   RETURN Win.MPARAM(FALSE);
  86. END ClientWinProc;
  87.  
  88.  
  89. (*# restore *)
  90. (*---------------------  End of window procedure  ----------------------*)
  91.  
  92. BEGIN
  93.   flcreateFlags := Win.FCF_TITLEBAR + Win.FCF_SYSMENU + Win.FCF_SIZEBORDER +
  94.                    Win.FCF_MINMAX + Win.FCF_SHELLPOSITION + Win.FCF_TASKLIST;
  95.  
  96.   hab := Win.Initialize(NULL);
  97.   hmq := Win.CreateMsgQueue(hab,0);
  98.  
  99.  
  100.   IF NOT Win.RegisterClass(             (* Register window class        *)
  101.      hab,                               (* Anchor block handle          *)
  102.      szClientClass,                     (* Window class name            *)
  103.      ClientWinProc,                  (* Address of window procedure  *)
  104.      0,                                 (* No special Class Style       *)
  105.      0                                  (* No extra window words        *)
  106.      ) THEN Error END;
  107.  
  108.   hwnd := Win.CreateStdWindow(
  109.               Win.HWND_DESKTOP,
  110.               Win.WS_VISIBLE,
  111.               flcreateFlags,
  112.               szClientClass,
  113.               ' - Client Window',
  114.               0,
  115.               NULL,
  116.               0,
  117.               hwndClient);
  118.  
  119.  
  120.   WHILE( Win.GetMsg( hab, qmsg, HWND(NULL), 0, 0 ) ) DO
  121.     r := Win.DispatchMsg( hab, qmsg );
  122.   END;
  123.  
  124.   IF NOT Win.DestroyWindow(hwndClient) THEN      (* and                          *)
  125.     Error;
  126.   END;
  127.  
  128.   IF NOT Win.DestroyWindow(hwnd) THEN      (* and                          *)
  129.     Error;
  130.   END;
  131.  
  132.   IF NOT Win.DestroyMsgQueue(hmq) THEN      (* and                          *)
  133.     Error;
  134.   END;
  135.  
  136.   IF NOT Win.Terminate(hab) THEN            (* terminate the application    *)
  137.     Error;
  138.   END;
  139.  
  140.   HALT;
  141.  
  142. END CLICK.
  143.