home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / PM-M2.ZIP / FAMILY.MOD < prev    next >
Text File  |  1990-08-05  |  5KB  |  124 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. (*    An example of how to create a "family" of windows. The two extra win-   *)
  32. (*    dows that appear on the screen are child windows of the client window.  *)
  33. (*    When you terminate the client window, its children will also be         *)
  34. (*    terminated.                                                             *)
  35. (*    Source code on page 61.                                                 *)
  36. (*----------------------------------------------------------------------------*)
  37.  
  38. MODULE FAMILY;
  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.  
  45. TYPE
  46.   StrPtr = POINTER TO ARRAY[0..0] OF CHAR;
  47.  
  48. CONST
  49.   WINDOW_ID = 1;
  50.  
  51. VAR
  52.   hab                   : HAB;
  53.   hmq                   : Win.HMQ;
  54.   qmsg                  : Win.QMSG;
  55.   client,
  56.   hwnd,
  57.   hwndSibling1,
  58.   hwndSibling2,
  59.   hwndChildOf2          : HWND;
  60.   r                     : Win.MRESULT;
  61.   flcreateFlags1,
  62.   flcreateFlags2        : LSET;
  63.  
  64. PROCEDURE Error;
  65. BEGIN
  66. END Error;
  67.  
  68. BEGIN
  69.   flcreateFlags1 := Win.FCF_TITLEBAR + Win.FCF_SYSMENU + Win.FCF_SIZEBORDER +
  70.                     Win.FCF_MINMAX + Win.FCF_SHELLPOSITION + Win.FCF_TASKLIST;
  71.  
  72.   flcreateFlags2 := Win.FCF_TITLEBAR + Win.FCF_SIZEBORDER +
  73.                     Win.FCF_MINMAX + Win.FCF_SHELLPOSITION;
  74.  
  75.   hab := Win.Initialize(NULL);
  76.   hmq := Win.CreateMsgQueue(hab,0);
  77.  
  78.  
  79.   hwndSibling1 := Win.CreateStdWindow(
  80.                   Win.HWND_DESKTOP,
  81.                   Win.WS_VISIBLE,flcreateFlags1,StrPtr(NULL)^,
  82.                   ' - Sibling 1',0,NULL,0,client);
  83.  
  84.   hwndSibling2 := Win.CreateStdWindow(
  85.                   Win.HWND_DESKTOP,
  86.                   Win.WS_VISIBLE,flcreateFlags2,StrPtr(NULL)^,
  87.                   ' Sibling 2',0,NULL,0,client);
  88.  
  89.   hwndChildOf2 := Win.CreateWindow(
  90.                   hwndSibling2,
  91.                   StrPtr(Win.WC_SCROLLBAR)^,
  92.                   StrPtr(NULL)^,
  93.                   Win.WS_VISIBLE + Win.SBS_HORZ,
  94.                   100,100,400,30,NULL,Win.HWND_TOP,WINDOW_ID,
  95.                   NIL,NIL);
  96.  
  97.   WHILE (Win.GetMsg(hab,qmsg,HWND(NULL),0,0)) DO
  98.     r := Win.DispatchMsg( hab, qmsg );
  99.   END;
  100.  
  101.   IF NOT Win.DestroyWindow(hwndChildOf2) THEN
  102.     Error;
  103.   END;
  104.  
  105.   IF NOT Win.DestroyWindow(hwndSibling2) THEN
  106.     Error;
  107.   END;
  108.  
  109.   IF NOT Win.DestroyWindow(hwndSibling1) THEN
  110.     Error;
  111.   END;
  112.  
  113.   IF NOT Win.DestroyMsgQueue( hmq ) THEN
  114.     Error;
  115.   END;
  116.  
  117.   IF NOT Win.Terminate( hab ) THEN            (* terminate the application    *)
  118.     Error;
  119.   END;
  120.  
  121.   HALT;
  122.  
  123. END FAMILY.
  124.