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