home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / OS2BAS.ZIP / WELCOME3.BAS < prev    next >
BASIC Source File  |  1989-09-11  |  7KB  |  172 lines

  1. '----------------------------------------------------------------------------
  2. ' WELCOME3.BAS -- A Program that Creates a Top-Level Window and Two Children
  3. '----------------------------------------------------------------------------
  4. REM $INCLUDE: 'PMBase.BI'
  5. REM $INCLUDE: 'OS2Def.BI'
  6. REM $INCLUDE: 'WinFrame.BI'
  7. REM $INCLUDE: 'WinMan1.BI'
  8. REM $INCLUDE: 'WinMan2.BI'
  9. REM $INCLUDE: 'WinPoint.BI'
  10. REM $INCLUDE: 'GpiColor.BI'
  11. DECLARE FUNCTION RegBas1&
  12.  
  13. DIM aqmsg AS QMSG
  14.  
  15. szClientClass$ = "Welcome3" + CHR$(0)
  16. szChildClass$  = "Welcome3.Child" + CHR$(0)
  17.  
  18. flFrameFlags& = FCFTITLEBAR     OR FCFSYSMENU OR _
  19.         FCFSIZEBORDER     OR FCFMINMAX  OR _
  20.         FCFSHELLPOSITION OR FCFTASKLIST
  21.  
  22. hab& = WinInitialize(0)
  23. hmq& = WinCreateMsgQueue(hab&, 0)
  24.  
  25. bool% = WinRegisterClass(_
  26.              hab&,_                             ' Anchor block handle
  27.              MakeLong(VARSEG(szClientClass$),_  ' Name of class being registered
  28.                         SADD(szClientClass$)),_
  29.              RegBas,_                           ' Window procedure for class
  30.              CSSIZEREDRAW,_                     ' Class style
  31.              0)                                 ' Extra bytes to reserve
  32.  
  33. bool% = WinRegisterClass(_
  34.              hab&,_                             ' Anchor block handle
  35.              MakeLong(VARSEG(szChildClass$),_   ' Name of class being registered
  36.                         SADD(szChildClass$)),_
  37.              RegBas1,_                          ' Window procedure for class
  38.              CSSIZEREDRAW,_                     ' Class style
  39.              4)                                 ' Extra bytes to reserve
  40.  
  41.     '-------------------------
  42.     ' Create top-level window
  43.     '-------------------------
  44.  
  45. hwndFrame& = WinCreateStdWindow (_
  46.              HWNDDESKTOP,_                      ' Parent window handle
  47.              WSVISIBLE,_                        ' Style of frame window
  48.              MakeLong (VARSEG(flFrameFlags&),_  ' Pointer to control data
  49.                        VARPTR(flFrameFlags&)),_
  50.              MakeLong (VARSEG(szClientClass$),_ ' Client window class name
  51.                          SADD(szClientClass$)),_
  52.              0,_                                ' Title bar text
  53.              0,_                                ' Style of client window
  54.              0,_                                ' Module handle for resources
  55.              0,_                                ' ID of resources
  56.              MakeLong (VARSEG(hwndClient&),_    ' Pointer to client window handle
  57.                        VARPTR(hwndClient&)))
  58.  
  59. bool% = WinSendMsg(hwndFrame&, WMSETICON,_
  60.                      WinQuerySysPointer(HWNDDESKTOP, SPTRAPPICON, FALSE),_
  61.                      0)
  62.  
  63.     '--------------------------
  64.     ' Create two child windows
  65.     '--------------------------
  66.  
  67. flFrameFlags& = flFrameFlags& AND NOT(FCFTASKLIST)
  68.  
  69. name1$ = "Child No. 1" + CHR$(0)
  70. hwndChildFrame1& = WinCreateStdWindow (_
  71.              hwndClient&,_                      ' Parent window handle
  72.              WSVISIBLE,_                        ' Style of frame window
  73.              MakeLong (VARSEG(flFrameFlags&),_  ' Pointer to control data
  74.                        VARPTR(flFrameFlags&)),_
  75.              MakeLong (VARSEG(szChildClass$),_  ' Client window class name
  76.                          SADD(szChildClass$)),_
  77.              MakeLong (VARSEG(name1$),_         ' Title bar text
  78.                          SADD(name1$)),_
  79.              0,_                                ' Style of client window
  80.              0,_                                ' Module handle for resources
  81.              0,_                                ' ID of resources
  82.              MakeLong(VARSEG(hwndChildClient1&),_' Pointer to client window handle
  83.                       VARPTR(hwndChildClient1&)))
  84.  
  85. name2$ = "Child No. 2" + CHR$(0)
  86. hwndChildFrame2& = WinCreateStdWindow (_
  87.              hwndClient&,_                      ' Parent window handle
  88.              WSVISIBLE,_                        ' Style of frame window
  89.              MakeLong (VARSEG(flFrameFlags&),_  ' Pointer to control data
  90.                        VARPTR(flFrameFlags&)),_
  91.              MakeLong (VARSEG(szChildClass$),_  ' Client window class name
  92.                          SADD(szChildClass$)),_
  93.              MakeLong (VARSEG(name2$),_         ' Title bar text
  94.                          SADD(name2$)),_
  95.              0,_                                ' Style of client window
  96.              0,_                                ' Module handle for resources
  97.              0,_                                ' ID of resources
  98.              MakeLong(VARSEG(hwndChildClient2&),_' Pointer to client window handle
  99.                       VARPTR(hwndChildClient2&)))
  100.  
  101. bool% = WinSendMsg(hwndChildFrame1&, WMSETICON,_
  102.              WinQuerySysPointer(HWNDDESKTOP, SPTRAPPICON, FALSE),_
  103.              0)
  104.  
  105. bool% = WinSendMsg(hwndChildFrame2&, WMSETICON,_
  106.              WinQuerySysPointer(HWNDDESKTOP, SPTRAPPICON, FALSE),_
  107.              0)
  108.  
  109.     '-----------------------------------------------------
  110.     ' Set reserved area of window to text string pointers
  111.     '-----------------------------------------------------
  112.  
  113. msg1$ = "I'm a child ..."+CHR$(0)
  114. bool% = WinSetWindowPtr(hwndChildClient1&, QWLUSER, MakeLong(VARSEG(msg1$),SADD(msg1$)))
  115. msg2$ = "... Me too!"+CHR$(0)
  116. bool% = WinSetWindowPtr(hwndChildClient2&, QWLUSER, MakeLong(VARSEG(msg2$),SADD(msg2$)))
  117.  
  118. WHILE (WinGetMsg(hab&, MakeLong(VARSEG(aqmsg), VARPTR(aqmsg)), 0, 0, 0))
  119.   bool% = WinDispatchMsg(hab&, MakeLong(VARSEG(aqmsg), VARPTR(aqmsg)))
  120. WEND
  121.  
  122. bool% = WinDestroyWindow(hwndFrame&)
  123. bool% = WinDestroyMsgQueue(hmq&)
  124. bool% = WinTerminate(hab&)
  125.  
  126. END
  127.  
  128. FUNCTION ClientWndProc&(hwnd&, msg%, mp1&, mp2&)
  129.      szText$ = "I'm the parent of two children" + CHR$(0)
  130.      DIM rcl AS RECTL
  131.  
  132.      ClientWndProc& = 0
  133.      SELECT CASE msg%
  134.     CASE WMPAINT
  135.         hps& = WinBeginPaint(hwnd&, 0, 0)
  136.             bool% = WinQueryWindowRect(hwnd&, MakeLong(VARSEG(rcl), VARPTR(rcl)))
  137.             bool% = WinDrawText(hps&,_
  138.                                 -1,_
  139.                                 MakeLong(VARSEG(szText$), SADD(szText$)),_
  140.                                 MakeLong(VARSEG(rcl), VARPTR(rcl)),_
  141.                                 CLRNEUTRAL,_
  142.                                 CLRBACKGROUND,_
  143.                                 DTCENTER OR DTVCENTER OR DTERASERECT)
  144.             bool% = WinEndPaint(hps&)
  145.     CASE ELSE
  146.             ClientWndProc& = WinDefWindowProc(hwnd&, msg%, mp1&, mp2&)
  147.     END SELECT
  148. END FUNCTION
  149.  
  150. FUNCTION ClientWndProc1&(hwnd&, msg%, mp1&, mp2&)
  151.      DIM rcl AS RECTL
  152.  
  153.      ClientWndProc1& = 0
  154.      SELECT CASE msg%
  155.     CASE WMPAINT
  156.         hps& = WinBeginPaint(hwnd&, 0, 0)
  157.             bool% = WinQueryWindowRect(hwnd&, MakeLong(VARSEG(rcl), VARPTR(rcl)))
  158.             bool% = WinDrawText(hps&,_
  159.                                 -1,_
  160.                                 WinQueryWindowPtr(hwnd&, QWLUSER),_
  161.                                 MakeLong(VARSEG(rcl), VARPTR(rcl)),_
  162.                                 CLRNEUTRAL,_
  163.                                 CLRBACKGROUND,_
  164.                                 DTCENTER OR DTVCENTER OR DTERASERECT)
  165.             bool% = WinEndPaint(hps&)
  166.         CASE WMCLOSE
  167.             bool% = WinDestroyWindow (WinQueryWindow (hwnd&, QWPARENT, FALSE))
  168.     CASE ELSE
  169.             ClientWndProc1& = WinDefWindowProc(hwnd&, msg%, mp1&, mp2&)
  170.     END SELECT
  171. END FUNCTION
  172.