home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / PM-M2.ZIP / CLICK.MOD < prev    next >
Text File  |  1990-08-05  |  6KB  |  145 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, August 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. MODULE CLICK;
  38.  
  39. (*# call(same_ds => off) *)
  40.  
  41. IMPORT OS2DEF,Win,Gpi,Dos,Lib,SYSTEM,IO;
  42. FROM OS2DEF IMPORT HDC,HRGN,HAB,HPS,HBITMAP,HWND,HMODULE,HSEM,
  43.                    POINTL,RECTL,PID,TID,LSET,NULL,
  44.                    COLOR,NullVar,NullStr,BOOL ;
  45.  
  46. TYPE
  47.   StrPtr = POINTER TO ARRAY[0..0] OF CHAR;
  48.  
  49. CONST
  50.   szClientClass = 'Client Window';
  51.  
  52. VAR
  53.   hab           : HAB;
  54.   hmq           : Win.HMQ;
  55.   qmsg          : Win.QMSG;
  56.   hwndClient,
  57.   client,
  58.   hwnd          : HWND;
  59.   r             : Win.MRESULT;
  60.   flcreateFlags : LSET;
  61.  
  62. PROCEDURE Error;
  63. BEGIN
  64. END Error;
  65.  
  66. (*--------------------  Start of window procedure  ---------------------*)
  67. (*# save,call(near_call=>off,reg_param=>(),reg_saved=>(di,si,ds,es,st1,st2)) *)
  68.  
  69. PROCEDURE ClientWinProc(
  70.                        hwnd : HWND;
  71.                        msg:CARDINAL;
  72.                        mp1,mp2:Win.MPARAM)
  73.                        : Win.MRESULT;
  74.  
  75.  
  76. VAR
  77.   mm : Win.MOUSEMSG;
  78.  
  79. BEGIN
  80.   CASE msg OF
  81.     | Win.WM_BUTTON1DOWN : Win.Alarm(Win.HWND_DESKTOP,Win.WA_NOTE);
  82.                            RETURN Win.MPARAM(TRUE);
  83.     | Win.WM_ERASEBACKGROUND : RETURN Win.MPARAM(TRUE)
  84.   ELSE
  85.     RETURN Win.DefWindowProc(hwnd, msg, mp1, mp2)
  86.   END;
  87.   RETURN Win.MPARAM(FALSE);
  88. END ClientWinProc;
  89.  
  90.  
  91. (*# restore *)
  92. (*---------------------  End of window procedure  ----------------------*)
  93.  
  94. BEGIN
  95.   flcreateFlags := Win.FCF_TITLEBAR + Win.FCF_SYSMENU + Win.FCF_SIZEBORDER +
  96.                    Win.FCF_MINMAX + Win.FCF_SHELLPOSITION + Win.FCF_TASKLIST;
  97.  
  98.   hab := Win.Initialize(NULL);
  99.   hmq := Win.CreateMsgQueue(hab,0);
  100.  
  101.  
  102.   IF NOT Win.RegisterClass(             (* Register window class        *)
  103.      hab,                               (* Anchor block handle          *)
  104.      szClientClass,                     (* Window class name            *)
  105.      ClientWinProc,                  (* Address of window procedure  *)
  106.      0,                                 (* No special Class Style       *)
  107.      0                                  (* No extra window words        *)
  108.      ) THEN Error END;
  109.  
  110.   hwnd := Win.CreateStdWindow(
  111.               Win.HWND_DESKTOP,
  112.               Win.WS_VISIBLE,
  113.               flcreateFlags,
  114.               szClientClass,
  115.               ' - Client Window',
  116.               0,
  117.               NULL,
  118.               0,
  119.               hwndClient);
  120.  
  121.  
  122.   WHILE( Win.GetMsg( hab, qmsg, HWND(NULL), 0, 0 ) ) DO
  123.     r := Win.DispatchMsg( hab, qmsg );
  124.   END;
  125.  
  126.   IF NOT Win.DestroyWindow(hwndClient) THEN      (* and                          *)
  127.     Error;
  128.   END;
  129.  
  130.   IF NOT Win.DestroyWindow(hwnd) THEN      (* and                          *)
  131.     Error;
  132.   END;
  133.  
  134.   IF NOT Win.DestroyMsgQueue(hmq) THEN      (* and                          *)
  135.     Error;
  136.   END;
  137.  
  138.   IF NOT Win.Terminate(hab) THEN            (* terminate the application    *)
  139.     Error;
  140.   END;
  141.  
  142.   HALT;
  143.  
  144. END CLICK.
  145.