home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / OS2BAS.ZIP / WINFRAME.BAS < prev    next >
BASIC Source File  |  1989-08-27  |  5KB  |  141 lines

  1. '***********************************************************
  2. '* 
  3. '* Program Name: WinFrame.BAS
  4. '*
  5. '* Include File: WinFrame.BI
  6. '*
  7. '* Functions   :
  8. '*               WinCreateFrameControls
  9. '*               WinFlashWindow
  10. '*               WinCalcFrameRect
  11. '*               WinGetMaxPosition
  12. '*               WinGetMinPosition
  13. '*               WinFormatFrame
  14. '*
  15. '* Description : This program demonstrates the functions 
  16. '*               contained in the WinFrame.BI include file.
  17. '*               Because many of the calls do not cause an
  18. '*               obvious change to the window, some 
  19. '*               information is written to the file, 
  20. '*               WinFrame.OUT.
  21. '***********************************************************
  22.  
  23. '*********         Initialization section        ***********
  24.  
  25. REM $INCLUDE: 'PMBase.BI'
  26. REM $INCLUDE: 'OS2Def.BI'
  27. REM $INCLUDE: 'WinMan1.BI'
  28. REM $INCLUDE: 'WinFrame.BI'
  29.  
  30. DIM aqmsg                              AS QMSG
  31. DIM aswp                               AS SWP
  32. DIM swparr(FIDCLIENT - FIDSYSMENU + 1) AS SWP
  33. DIM FrameRect                          AS RECTL
  34. DIM afcd                               AS FRAMECDATA
  35.  
  36. OPEN "WinFrame.OUT" FOR OUTPUT AS #1
  37.  
  38. flFrameflags& =  FCFSYSMENU       OR_
  39.                  FCFSIZEBORDER    OR FCFMINMAX OR_
  40.                  FCFSHELLPOSITION OR FCFTASKLIST
  41.  
  42. szClientClass$ = "ClassName" + CHR$(0)
  43.  
  44. hab&  = WinInitialize    (0)
  45. hmq&  = WinCreateMsgQueue(hab&, 0)
  46.  
  47. bool% = WinRegisterClass(hab&,_
  48.         MakeLong(VARSEG(szClientClass$), SADD(szClientClass$)),_
  49.         RegBas, 0, 0)
  50.  
  51. hwndFrame& = WinCreateStdWindow(_
  52.              HWNDDESKTOP,_
  53.              WSINVISIBLE,_
  54.              MakeLong(VARSEG(flFrameflags&),  VARPTR(flFrameflags&)),_
  55.              MakeLong(VARSEG(szClientClass$), SADD(szClientClass$)),_
  56.              0, 0, 0, 0,_
  57.              MakeLong(VARSEG(hwndClient&),    VARPTR(hwndClient&)))
  58.  
  59. '*********         Frame function calls         ************
  60.  
  61. 'The call below to WinCreateFrameControls sets title bar
  62.  
  63. titlebar$          = "NewTitle" + CHR$(0)
  64. afcd.cb            = 10
  65. afcd.flCreateFlags = FCFTITLEBAR
  66. bool% = WinCreateFrameControls(     hwndFrame&,_
  67.         MakeLong(VARSEG(afcd),      VARPTR(afcd)),_
  68.         MakeLong(VARSEG(titlebar$), SADD(titlebar$)))
  69. bool% = WinShowWindow (hwndFrame&, 1)
  70.  
  71. bool% = WinFlashWindow(hwndFrame&, 1)  'Causes window to flash
  72.  
  73. ' The following calls set and check various positions on 
  74.  
  75. bool% = WinCalcFrameRect(hwndFrame&,_
  76.         MakeLong(VARSEG(FrameRect), VARPTR(FrameRect)), 0)
  77.   PRINT #1, "WinCalcFrameRect:";
  78.   PRINT #1, "("; FrameRect.xLeft;  ","; FrameRect.yBottom; ")-";
  79.   PRINT #1, "("; FrameRect.xRight; ","; FrameRect.yTop;    ")"
  80.  
  81. bool% = WinSetWindowPos  (hwndFrame&, 0, 0, 0, 0, 0, SWPMAXIMIZE)
  82. bool% = WinGetMaxPosition(hwndFrame&,_
  83.         MakeLong(VARSEG(aswp), VARPTR(aswp)))
  84.   PRINT #1, "WinGetMaxPosition:"
  85.   PRINT #1, aswp.fs,
  86.   PRINT #1, "("; aswp.x;  ","; aswp.y;  ")",
  87.   PRINT #1, "("; aswp.cx; ","; aswp.cy; ")"
  88.  
  89. bool% = WinSetWindowPos  (hwndFrame&, 0, 0, 0, 0, 0, SWPMINIMIZE)
  90. bool% = WinGetMinPosition(hwndFrame&,_
  91.         MakeLong(VARSEG(aswp), VARPTR(aswp)), 0)
  92.   PRINT #1, "WinGetMinPosition:"
  93.   PRINT #1, aswp.fs,
  94.   PRINT #1, "("; aswp.x;  ","; aswp.y;  ")",
  95.   PRINT #1, "("; aswp.cx; ","; aswp.cy; ")"
  96.  
  97. bool% = WinSetWindowPos(hwndFrame&, 0, 0, 0, 0, 0, SWPRESTORE)
  98. bool% = WinFormatFrame(_
  99.      hwndFrame&,_
  100.      MakeLong(VARSEG(FrameRect),   VARPTR(FrameRect)),_
  101.      MakeLong(VARSEG(swparr(0)),   VARPTR(swparr(0))),_
  102.      FIDCLIENT - FIDSYSMENU + 1,_
  103.      MakeLong(VARSEG(hwndClient&), VARPTR(hwndClient&)))
  104.   PRINT #1, "WinFormatFrame:"
  105.   FOR i% = 0 TO FIDCLIENT - FIDSYSMENU + 1
  106.     PRINT #1, swparr(i%).fs,
  107.     PRINT #1, "("; swparr(i%).x;  ","; swparr(i%).y;  ")",
  108.     PRINT #1, "("; swparr(i%).cx; ","; swparr(i%).cy; ")"
  109.   NEXT i%
  110.  
  111. '*************         Message loop          ***************
  112.  
  113. WHILE (WinGetMsg(hab&, MakeLong(VARSEG(aqmsg), VARPTR(aqmsg)), 0, 0, 0))
  114.   bool% = WinDispatchMsg(hab&, MakeLong(VARSEG(aqmsg), VARPTR(aqmsg)))
  115. WEND
  116.  
  117. '*************         Finalize section         ************
  118.  
  119. bool% = WinDestroyWindow   (hwndFrame&)
  120. bool% = WinDestroyMsgQueue (hmq&)
  121. bool% = WinTerminate       (hab&)
  122.  
  123. END
  124.  
  125. '***********         Window procedure          *************
  126.  
  127. FUNCTION ClientWndProc& (hwnd&, msg%, mp1&, mp2&) STATIC
  128.      DIM ClientRect AS RECTL
  129.      ClientWndProc& = 0
  130.      SELECT CASE msg%
  131.      CASE WMPAINT     'Paint the window with background color
  132.         hps&  = WinBeginPaint(hwnd&, 0,_
  133.                 MakeLong(VARSEG(ClientRect), VARPTR(ClientRect)))
  134.         bool% = WinFillRect(hps&,_
  135.                 MakeLong(VARSEG(ClientRect), VARPTR(ClientRect)),0)
  136.         bool% = WinEndPaint(hps&)
  137.      CASE ELSE        'Pass control to system for other messages
  138.         ClientWndProc& = WinDefWindowProc(hwnd&, msg%, mp1&, mp2&)
  139.      END SELECT
  140. END FUNCTION
  141.