home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / PM-M2B.ZIP / DEFWIN.MOD < prev    next >
Text File  |  1990-10-04  |  6KB  |  137 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: DEFWIN.MOD                                                 *)
  31. (*    Creates a basic client window on the desktop that can be moved and      *)
  32. (*    resized.  Because no instructions are included to tell the window       *)
  33. (*    to repaint its background when it is moved, it has the effect of "clip- *)
  34. (*    ping" the contents of the screen below and taking a copy with it.       *)
  35. (*    Source code is on page 70.                                              *)
  36. (*----------------------------------------------------------------------------*)
  37.  
  38. (*# call(same_ds => off) *)
  39. (*# data(heap_size=> 3000) *)
  40.  
  41. MODULE DEFWIN;
  42.  
  43. IMPORT OS2DEF,Win,Gpi,Dos,Lib,SYSTEM,IO;
  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.   szClientClass = 'Client Window';
  54.  
  55. VAR
  56.   hab           : HAB;
  57.   hmq           : Win.HMQ;
  58.   qmsg          : Win.QMSG;
  59.   hwndClient,
  60.   client,
  61.   hwnd          : HWND;
  62.   r             : Win.MRESULT;
  63.   flcreateFlags : LSET;
  64.  
  65. PROCEDURE Error;
  66. BEGIN
  67. END Error;
  68.  
  69. (*--------------------  Start of window procedure  ---------------------*)
  70. (*# save,call(near_call=>off,reg_param=>(),reg_saved=>(di,si,ds,es,st1,st2)) *)
  71.  
  72. PROCEDURE ClientWinProc(
  73.                        hwnd : HWND;
  74.                        msg:CARDINAL;
  75.                        mp1,mp2:Win.MPARAM)
  76.                        : Win.MRESULT;
  77.  
  78. BEGIN
  79.   RETURN Win.DefWindowProc( hwnd, msg, mp1, mp2 );
  80. END ClientWinProc;
  81.  
  82.  
  83. (*# restore *)
  84. (*---------------------  End of window procedure  ----------------------*)
  85.  
  86. BEGIN
  87.   flcreateFlags := Win.FCF_TITLEBAR + Win.FCF_SYSMENU + Win.FCF_SIZEBORDER +
  88.                    Win.FCF_MINMAX + Win.FCF_SHELLPOSITION + Win.FCF_TASKLIST;
  89.  
  90.   hab := Win.Initialize(NULL);
  91.   hmq := Win.CreateMsgQueue(hab,0);
  92.  
  93.  
  94.   IF NOT Win.RegisterClass(             (* Register window class        *)
  95.      hab,                               (* Anchor block handle          *)
  96.      szClientClass,                     (* Window class name            *)
  97.      ClientWinProc,                  (* Address of window procedure  *)
  98.      0,                                 (* No special Class Style       *)
  99.      0                                  (* No extra window words        *)
  100.      ) THEN Error END;
  101.  
  102.   hwnd := Win.CreateStdWindow(
  103.               Win.HWND_DESKTOP,
  104.               Win.WS_VISIBLE,
  105.               flcreateFlags,
  106.               szClientClass,
  107.               ' - Client Window',
  108.               0,
  109.               NULL,
  110.               0,
  111.               hwndClient);
  112.  
  113.  
  114.   WHILE( Win.GetMsg( hab, qmsg, HWND(NULL), 0, 0 ) ) DO
  115.     r := Win.DispatchMsg( hab, qmsg );
  116.   END;
  117.  
  118.   IF NOT Win.DestroyWindow(hwndClient) THEN      (* and                          *)
  119.     Error;
  120.   END;
  121.  
  122.   IF NOT Win.DestroyWindow(hwnd) THEN      (* and                          *)
  123.     Error;
  124.   END;
  125.  
  126.   IF NOT Win.DestroyMsgQueue(hmq) THEN      (* and                          *)
  127.     Error;
  128.   END;
  129.  
  130.   IF NOT Win.Terminate(hab) THEN            (* terminate the application    *)
  131.     Error;
  132.   END;
  133.  
  134.   HALT;
  135.  
  136. END DEFWIN.
  137.