home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / PM-M2B.ZIP / FAMILY.MOD < prev    next >
Text File  |  1990-10-04  |  5KB  |  128 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. (*    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. (*# call(same_ds => off) *)
  39. (*# data(heap_size=> 3000) *)
  40.  
  41. MODULE FAMILY;
  42.  
  43. IMPORT OS2DEF,Win,Gpi,Dos,Lib,SYSTEM;
  44. FROM OS2DEF IMPORT HDC,HRGN,HAB,HPS,HBITMAP,HWND,HMODULE,HSEM,
  45.                    POINTL,RECTL,PID,TID,LSET,NULL,
  46.                    COLOR,NullVar,NullStr,BOOL ;
  47. FROM OS2MAC IMPORT SHORT1FROMMP,SHORT2FROMMP,MPFROMSHORT,MPFROM2SHORT;
  48.  
  49. TYPE
  50.   StrPtr = POINTER TO ARRAY[0..0] OF CHAR;
  51.  
  52. CONST
  53.   WINDOW_ID = 1;
  54.  
  55. VAR
  56.   hab                   : HAB;
  57.   hmq                   : Win.HMQ;
  58.   qmsg                  : Win.QMSG;
  59.   client,
  60.   hwnd,
  61.   hwndSibling1,
  62.   hwndSibling2,
  63.   hwndChildOf2          : HWND;
  64.   r                     : Win.MRESULT;
  65.   flcreateFlags1,
  66.   flcreateFlags2        : LSET;
  67.  
  68. PROCEDURE Error;
  69. BEGIN
  70. END Error;
  71.  
  72. BEGIN
  73.   flcreateFlags1 := Win.FCF_TITLEBAR + Win.FCF_SYSMENU + Win.FCF_SIZEBORDER +
  74.                     Win.FCF_MINMAX + Win.FCF_SHELLPOSITION + Win.FCF_TASKLIST;
  75.  
  76.   flcreateFlags2 := Win.FCF_TITLEBAR + Win.FCF_SIZEBORDER +
  77.                     Win.FCF_MINMAX + Win.FCF_SHELLPOSITION;
  78.  
  79.   hab := Win.Initialize(NULL);
  80.   hmq := Win.CreateMsgQueue(hab,0);
  81.  
  82.  
  83.   hwndSibling1 := Win.CreateStdWindow(
  84.                   Win.HWND_DESKTOP,
  85.                   Win.WS_VISIBLE,flcreateFlags1,StrPtr(NULL)^,
  86.                   ' - Sibling 1',0,NULL,0,HWND(NullVar));
  87.  
  88.   hwndSibling2 := Win.CreateStdWindow(
  89.                   Win.HWND_DESKTOP,
  90.                   Win.WS_VISIBLE,flcreateFlags2,StrPtr(NULL)^,
  91.                   ' Sibling 2',0,NULL,0,HWND(NullVar));
  92.  
  93.   hwndChildOf2 := Win.CreateWindow(
  94.                   hwndSibling2,
  95.                   StrPtr(Win.WC_SCROLLBAR)^,
  96.                   StrPtr(NULL)^,
  97.                   Win.WS_VISIBLE + Win.SBS_HORZ,
  98.                   100,100,400,30,NULL,Win.HWND_TOP,WINDOW_ID,
  99.                   NIL,NIL);
  100.  
  101.   WHILE (Win.GetMsg(hab,qmsg,HWND(NULL),0,0)) DO
  102.     r := Win.DispatchMsg( hab, qmsg );
  103.   END;
  104.  
  105.   IF NOT Win.DestroyWindow(hwndChildOf2) THEN
  106.     Error;
  107.   END;
  108.  
  109.   IF NOT Win.DestroyWindow(hwndSibling2) THEN
  110.     Error;
  111.   END;
  112.  
  113.   IF NOT Win.DestroyWindow(hwndSibling1) THEN
  114.     Error;
  115.   END;
  116.  
  117.   IF NOT Win.DestroyMsgQueue( hmq ) THEN
  118.     Error;
  119.   END;
  120.  
  121.   IF NOT Win.Terminate( hab ) THEN            (* terminate the application    *)
  122.     Error;
  123.   END;
  124.  
  125.   HALT;
  126.  
  127. END FAMILY.
  128.