home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / PM-M2B.ZIP / ICON.MOD < prev    next >
Text File  |  1990-10-04  |  5KB  |  122 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 177.                                                                 *)
  32. (*  Creates a client window.  When window is minimized the icon is displayed  *)
  33. (*  which was created with the icon editor and named ICON.ICO.                *)
  34. (*----------------------------------------------------------------------------*)
  35. (*  Compiling Notes:                                                          *)
  36. (*                                                                            *)
  37. (*  The following files should be available:                                  *)
  38. (*  ICON.H, ICON.RC                                                           *)
  39. (*                                                                            *)
  40. (*  Add the line: "run rc %N" to the end of your project file.  This will     *)
  41. (*  cause TS to invode the Microsoft resource compiler after it has created   *)
  42. (*  the EXE file.  You also should have rc.exe in your path along with the    *)
  43. (*  OS/2 header files located in a directory that is referenced by the OS/2   *)
  44. (*  environment variable: INCLUDE.  For example SET INCLUDE = C:\TS\INCLUDE.  *)
  45. (*                                                                            *)
  46. (*----------------------------------------------------------------------------*)
  47.  
  48. (*# call(same_ds => off) *)
  49. (*# data(heap_size=> 3000) *)
  50.  
  51. MODULE ICON;
  52.  
  53. IMPORT OS2DEF,Win,Gpi,Dos,Lib,SYSTEM;
  54. FROM OS2DEF IMPORT HDC,HRGN,HAB,HPS,HBITMAP,HWND,HMODULE,HSEM,
  55.                    POINTL,RECTL,PID,TID,LSET,NULL,
  56.                    COLOR,NullVar,NullStr,BOOL ;
  57. FROM OS2MAC IMPORT SHORT1FROMMP,SHORT2FROMMP,MPFROMSHORT,MPFROM2SHORT;
  58.  
  59. TYPE
  60.   StrPtr = POINTER TO ARRAY[0..0] OF CHAR;
  61.  
  62. CONST
  63.   szClientClass = 'Client Window';
  64.   ID_FRAMERC    = 1;
  65.  
  66. VAR
  67.   rslt          : INTEGER;
  68.   hab           : HAB;
  69.   hmq           : Win.HMQ;
  70.   qmsg          : Win.QMSG;
  71.   hwnd          : HWND;
  72.   r             : Win.MRESULT;
  73.   flcreateFlags : LSET;
  74.  
  75. (*--------------------  Error reporting procedure  ---------------------*)
  76. PROCEDURE Error;
  77. VAR
  78. BEGIN
  79. END Error;
  80. (*-----------------  End of Error reporting procedure  ------------------*)
  81.  
  82.  
  83. BEGIN
  84.   flcreateFlags := Win.FCF_TITLEBAR + Win.FCF_SYSMENU + Win.FCF_SIZEBORDER +
  85.                    Win.FCF_MINMAX + Win.FCF_SHELLPOSITION + Win.FCF_TASKLIST +
  86.                    Win.FCF_ICON;
  87.  
  88.   hab := Win.Initialize(NULL);
  89.   hmq := Win.CreateMsgQueue(hab,0);
  90.  
  91.   hwnd := Win.CreateStdWindow(
  92.               Win.HWND_DESKTOP,
  93.               Win.WS_VISIBLE,
  94.               flcreateFlags,
  95.               StrPtr(NULL)^,
  96.               ' - Minimize this window to see the icon',
  97.               0,
  98.               NULL,
  99.               ID_FRAMERC,
  100.               HWND(NullVar));
  101.  
  102.  
  103.   WHILE (Win.GetMsg(hab,qmsg,HWND(NULL),0,0)) DO
  104.     r := Win.DispatchMsg(hab,qmsg);
  105.   END;
  106.  
  107.   IF NOT Win.DestroyWindow(hwnd) THEN
  108.     Error;
  109.   END;
  110.  
  111.   IF NOT Win.DestroyMsgQueue(hmq) THEN
  112.     Error;
  113.   END;
  114.  
  115.   IF NOT Win.Terminate(hab) THEN
  116.     Error;
  117.   END;
  118.  
  119.   HALT;
  120.  
  121. END ICON.
  122.