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

  1. '--------------------------------------------------------------
  2. ' WELCOME2.BAS -- A Program that Creates Two Top-Level Windows
  3. '--------------------------------------------------------------
  4. REM $INCLUDE: 'PMBase.BI'
  5. REM $INCLUDE: 'WinFrame.BI'
  6. REM $INCLUDE: 'WinMan1.BI'
  7. REM $INCLUDE: 'WinPoint.BI'
  8. REM $INCLUDE: 'GpiColor.BI'
  9. DECLARE FUNCTION RegBas1&
  10.  
  11. DIM aqmsg AS QMSG
  12.  
  13. szClientClass1$ = "Welcome2.1" + CHR$(0)
  14. szClientClass2$ = "Welcome2.2" + CHR$(0)
  15.  
  16. flFrameFlags& = FCFTITLEBAR     OR FCFSYSMENU OR _
  17.         FCFSIZEBORDER     OR FCFMINMAX  OR _
  18.         FCFSHELLPOSITION OR FCFTASKLIST
  19.  
  20. hab& = WinInitialize(0)
  21. hmq& = WinCreateMsgQueue(hab&, 0)
  22.  
  23. bool% = WinRegisterClass(_
  24.              hab&,_                             ' Anchor block handle
  25.              MakeLong(VARSEG(szClientClass1$),_ ' Name of class being registered
  26.                         SADD(szClientClass1$)),_
  27.              RegBas,_                           ' Window procedure for class
  28.              CSSIZEREDRAW,_                     ' Class style
  29.              0)                                 ' Extra bytes to reserve
  30.  
  31. bool% = WinRegisterClass(_
  32.              hab&,_                             ' Anchor block handle
  33.              MakeLong(VARSEG(szClientClass2$),_ ' Name of class being registered
  34.                         SADD(szClientClass2$)),_
  35.              RegBas1,_                          ' Window procedure for class
  36.              CSSIZEREDRAW,_                     ' Class style
  37.              0)                                 ' Extra bytes to reserve
  38.  
  39. hwndFrame1& = 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(szClientClass1$),_' Client window class name
  45.                           SADD(szClientClass1$)),_
  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(hwndClient1&),_   ' Pointer to client window handle
  51.                         VARPTR(hwndClient1&)))
  52.  
  53. hwndFrame2& = WinCreateStdWindow (_
  54.               HWNDDESKTOP,_                      ' Parent window handle
  55.               WSVISIBLE,_                        ' Style of frame window
  56.               MakeLong (VARSEG(flFrameFlags&),_  ' Pointer to control data
  57.                         VARPTR(flFrameFlags&)),_
  58.               MakeLong (VARSEG(szClientClass2$),_' Client window class name
  59.                           SADD(szClientClass2$)),_
  60.               0,_                                ' Title bar text
  61.               0,_                                ' Style of client window
  62.               0,_                                ' Module handle for resources
  63.               0,_                                ' ID of resources
  64.               MakeLong (VARSEG(hwndClient2&),_   ' Pointer to client window handle
  65.                         VARPTR(hwndClient2&)))
  66.  
  67. bool% = WinSendMsg(hwndFrame1&, WMSETICON,_
  68.              WinQuerySysPointer(HWNDDESKTOP, SPTRAPPICON, FALSE),_
  69.              0)
  70.  
  71. bool% = WinSendMsg(hwndFrame2&, WMSETICON,_
  72.              WinQuerySysPointer(HWNDDESKTOP, SPTRAPPICON, FALSE),_
  73.              0)
  74.  
  75. WHILE (WinGetMsg(hab&, MakeLong(VARSEG(aqmsg), VARPTR(aqmsg)), 0, 0, 0))
  76.   bool% = WinDispatchMsg(hab&, MakeLong(VARSEG(aqmsg), VARPTR(aqmsg)))
  77. WEND
  78.  
  79. bool% = WinDestroyWindow(hwndFrame1&)
  80. bool% = WinDestroyWindow(hwndFrame2&)
  81. bool% = WinDestroyMsgQueue(hmq&)
  82. bool% = WinTerminate(hab&)
  83.  
  84. END
  85.  
  86. FUNCTION ClientWndProc&(hwnd&, msg%, mp1&, mp2&)
  87.      szText$ = "Welcome to Window No. 1" + CHR$(0)
  88.      DIM rcl AS RECTL
  89.  
  90.      ClientWndProc& = 0
  91.      SELECT CASE msg%
  92.     CASE WMPAINT
  93.         hps& = WinBeginPaint(hwnd&, 0, 0)
  94.             bool% = WinQueryWindowRect(hwnd&, MakeLong(VARSEG(rcl), VARPTR(rcl)))
  95.             bool% = WinDrawText(hps&,_
  96.                                 -1,_
  97.                                 MakeLong(VARSEG(szText$), SADD(szText$)),_
  98.                                 MakeLong(VARSEG(rcl), VARPTR(rcl)),_
  99.                                 CLRNEUTRAL,_
  100.                                 CLRBACKGROUND,_
  101.                                 DTCENTER OR DTVCENTER OR DTERASERECT)
  102.             bool% = WinEndPaint(hps&)
  103.     CASE ELSE
  104.             ClientWndProc& = WinDefWindowProc(hwnd&, msg%, mp1&, mp2&)
  105.     END SELECT
  106. END FUNCTION
  107.  
  108. FUNCTION ClientWndProc1&(hwnd&, msg%, mp1&, mp2&)
  109.      szText$ = "Welcome to Window No. 2" + CHR$(0)
  110.      DIM rcl AS RECTL
  111.  
  112.      ClientWndProc1& = 0
  113.      SELECT CASE msg%
  114.     CASE WMPAINT
  115.         hps& = WinBeginPaint(hwnd&, 0, 0)
  116.             bool% = WinQueryWindowRect(hwnd&, MakeLong(VARSEG(rcl), VARPTR(rcl)))
  117.             bool% = WinDrawText(hps&,_
  118.                                 -1,_
  119.                                 MakeLong(VARSEG(szText$), SADD(szText$)),_
  120.                                 MakeLong(VARSEG(rcl), VARPTR(rcl)),_
  121.                                 CLRNEUTRAL,_
  122.                                 CLRBACKGROUND,_
  123.                                 DTCENTER OR DTVCENTER OR DTERASERECT)
  124.             bool% = WinEndPaint(hps&)
  125.         CASE WMCLOSE
  126.             REM
  127.     CASE ELSE
  128.             ClientWndProc1& = WinDefWindowProc(hwnd&, msg%, mp1&, mp2&)
  129.     END SELECT
  130. END FUNCTION
  131.