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