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

  1. '------------------------------------------------------------------------------
  2. ' WELCOME4.BAS -- A Program that Creates a Top-Level Window and Three 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: 'WinPoint.BI'
  9. REM $INCLUDE: 'WinButtn.BI'
  10. REM $INCLUDE: 'WinMisc.BI'
  11. REM $INCLUDE: 'WinEntry.BI'
  12. REM $INCLUDE: 'WinDialg.BI'
  13. REM $INCLUDE: 'GpiColor.BI'
  14.  
  15. CONST IDBUTTON = 1
  16. CONST IDSCROLL = 2
  17. CONST IDENTRY  = 3
  18.  
  19. DIM aqmsg AS QMSG
  20. DIM rcl AS RECTL
  21.  
  22. szClientClass$ = "Welcome4" + CHR$(0)
  23.  
  24. flFrameFlags& = FCFTITLEBAR     OR FCFSYSMENU OR _
  25.         FCFSIZEBORDER     OR FCFMINMAX  OR _
  26.         FCFSHELLPOSITION OR FCFTASKLIST
  27.  
  28. hab& = WinInitialize(0)
  29. hmq& = WinCreateMsgQueue(hab&, 0)
  30.  
  31. bool% = WinRegisterClass(_
  32.              hab&,_                             ' Anchor block handle
  33.              MakeLong(VARSEG(szClientClass$),_  ' Name of class being registered
  34.                         SADD(szClientClass$)),_
  35.              RegBas,_                           ' Window procedure for class
  36.              0,_                                ' Class style
  37.              0)                                 ' Extra bytes to reserve
  38.  
  39. hwndFrame& = WinCreateStdWindow (_
  40.              HWNDDESKTOP,_                      ' Parent window handle
  41.              WSVISIBLE,_                        ' Style of frame window
  42.              MakeLong (VARSEG(flFrameFlags&),_  ' Pointer to control data
  43.                        VARPTR(flFrameFlags&)),_
  44.              MakeLong (VARSEG(szClientClass$),_ ' Client window class name
  45.                          SADD(szClientClass$)),_
  46.              0,_                                ' Title bar text
  47.              0,_                                ' Style of client window
  48.              0,_                                ' Module handle for resources
  49.              0,_                                ' ID of resources
  50.              MakeLong (VARSEG(hwndClient&),_    ' Pointer to client window handle
  51.                        VARPTR(hwndClient&)))
  52.  
  53. bool% = WinSendMsg(hwndFrame&, WMSETICON,_
  54.             WinQuerySysPointer(HWNDDESKTOP, SPTRAPPICON, FALSE),_
  55.             0)
  56.  
  57.     '--------------------------------------------------------
  58.     ' Find dimensions of client window for sizes of children
  59.     '--------------------------------------------------------
  60.  
  61. bool% = WinQueryWindowRect (hwndClient&, MakeLong(VARSEG(rcl), VARPTR(rcl)))
  62. rcl.xRight = rcl.xRight \ 3                      ' divide width in thirds
  63.  
  64.     '---------------------------
  65.     ' Create push button window
  66.     '---------------------------
  67.  
  68. button$ = "Big Button" + CHR$(0)
  69. bool% = WinCreateWindow (_
  70.            hwndClient&,_                             ' Parent window handle
  71.            WCBUTTON,_                                ' Window class
  72.            MakeLong(VARSEG(button$), SADD(button$)),_' Window text
  73.            WSVISIBLE OR BSPUSHBUTTON,_               ' Window style
  74.            10,_                                      ' Window position
  75.            10,_
  76.            rcl.xRight - 20,_                         ' Window size
  77.            rcl.yTop - 20,_
  78.            hwndClient&,_                             ' Owner window handle
  79.            HWNDBOTTOM,_                              ' Placement window handle
  80.            IDBUTTON,_                                ' Child window ID
  81.            0,_                                       ' Control data
  82.            0)                                        ' Presentation parameters
  83.  
  84.     '--------------------------
  85.     ' Create scroll bar window
  86.     '--------------------------
  87.  
  88. bool% = WinCreateWindow (_
  89.            hwndClient&,_                             ' Parent window handle
  90.            WCSCROLLBAR,_                             ' Window class
  91.            0,_                                       ' Window text
  92.            WSVISIBLE OR SBSVERT,_                    ' Window style
  93.            rcl.xRight + 10,_                         ' Window position
  94.            10,_
  95.            rcl.xRight - 20,_                         ' Window size
  96.            rcl.yTop - 20,_
  97.            hwndClient&,_                             ' Owner window handle
  98.            HWNDBOTTOM,_                              ' Placement window handle
  99.            IDSCROLL,_                                ' Child window ID
  100.            0,_                                       ' Control data
  101.            0)                                        ' Presentation parameters
  102.  
  103.     '---------------------------
  104.     ' Create entry field window
  105.     '---------------------------
  106.  
  107. bool% = WinCreateWindow (_
  108.            hwndClient&,_                             ' Parent window handle
  109.            WCENTRYFIELD,_                            ' Window class
  110.            0,_                                       ' Window text
  111.            WSVISIBLE OR ESMARGIN OR ESAUTOSCROLL,_   ' Window style
  112.            2 * rcl.xRight + 10,_                     ' Window position
  113.            10,_
  114.            rcl.xRight - 20,_                         ' Window size
  115.            rcl.yTop - 20,_
  116.            hwndClient&,_                             ' Owner window handle
  117.            HWNDBOTTOM,_                              ' Placement window handle
  118.            IDENTRY,_                                 ' Child window ID
  119.            0,_                                       ' Control data
  120.            0)                                        ' Presentation parameters
  121.  
  122. WHILE (WinGetMsg(hab&, MakeLong(VARSEG(aqmsg), VARPTR(aqmsg)), 0, 0, 0))
  123.   bool% = WinDispatchMsg(hab&, MakeLong(VARSEG(aqmsg), VARPTR(aqmsg)))
  124. WEND
  125.  
  126. bool% = WinDestroyWindow(hwndFrame&)
  127. bool% = WinDestroyMsgQueue(hmq&)
  128. bool% = WinTerminate(hab&)
  129.  
  130. END
  131.  
  132. FUNCTION ClientWndProc&(hwnd&, msg%, mp1&, mp2&)
  133.      DIM rcl AS RECTL
  134.  
  135.      ClientWndProc& = 0
  136.      SELECT CASE msg%
  137.         CASE WMCOMMAND
  138.             SELECT CASE mp1& AND 255
  139.                CASE IDBUTTON
  140.                    bool% = WinAlarm (HWNDDESKTOP, WANOTE)
  141.                    EXIT FUNCTION
  142.                CASE ELSE
  143.             END SELECT
  144.         CASE WMERASEBACKGROUND
  145.             ClientWndProc& = 1
  146.             EXIT FUNCTION
  147.         CASE ELSE
  148.      END SELECT
  149.      ClientWndProc& = WinDefWindowProc(hwnd&, msg%, mp1&, mp2&)
  150. END FUNCTION
  151.