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

  1. REM $INCLUDE: 'os2def.bi'
  2. REM $INCLUDE: 'pmbase.bi'
  3. REM $INCLUDE: 'opendlg.bi'
  4. REM $INCLUDE: 'winmisc.bi'
  5. REM $INCLUDE: 'wintrack.bi'
  6. REM $INCLUDE: 'gpibit.bi'
  7.  
  8. REM $INCLUDE: 'CAPTURE.INC'
  9.  
  10. '|***************************************************************************
  11. '|
  12. '| DIALGMOD.BAS:  Support module of CAPTURE.BAS
  13. '|
  14. '|***************************************************************************
  15. '| This FUNCTION controls the dialog box used by "SetFrameWindowSize"
  16. '|***************************************************************************
  17. FUNCTION ClientWndProc1& (hwnd&, msg%, mp1&, mp2&)
  18. SHARED hwndFrame&, cxScreen%, cyScreen%, newXFrame%, newYFrame%, minFrame%
  19. DIM rect AS RECTL
  20.   SELECT CASE msg%
  21.     CASE WMINITDLG
  22.     '|
  23.     '| Initialize dialogbox items
  24.     '|
  25.     '| Get current frame window size
  26.     '|
  27.       bool% = WinQueryWindowRect(hwndFrame&,_
  28.                                  MakeLong(VARSEG(rect), VARPTR(rect)))
  29.       newXFrame% = rect.xright
  30.       newYFrame% = rect.ytop
  31.     '|
  32.     '| Initialize entryfields for Frame width and height
  33.     '|
  34.       bool% = WinSetDlgItemShort(hwnd&,_
  35.                                  XENTRYFIELD,_
  36.                                  newXFrame%,_
  37.                                  1)
  38.       bool% = WinSetDlgItemShort(hwnd&,_
  39.                                  YENTRYFIELD,_
  40.                                  newYFrame%,_
  41.                                  1)
  42.     '|
  43.     '| Initialize horizontal and vertical scroll bars to range and initial
  44.     '| position
  45.     '|                           
  46.       bool& = WinSendDlgItemMsg(hwnd&, XSCROLLBAR,_
  47.                                 SBMSETSCROLLBAR,_
  48.                                 MakeLong(0, newXFrame%),_
  49.                                 MakeLong(cxScreen%, minFrame%))
  50.       bool& = WinSendDlgItemMsg(hwnd&, YSCROLLBAR,_
  51.                                 SBMSETSCROLLBAR,_
  52.                                 MakeLong(0, newYFrame%),_
  53.                                 MakeLong(cyScreen%, minFrame%))
  54.     CASE WMCOMMAND
  55.     '|
  56.     '| A dialog box pushbutton was selected
  57.     '|
  58.       CALL BreakLong(mp1&, dummy%, controlSelection%)
  59.       IF controlSelection% <> OKBUTTON THEN
  60.       '|
  61.       '| If button selected was not the OK button, dismiss the dialog box
  62.       '| and return the ID of the button selected to CALLing routine
  63.       '|
  64.         bool% = WinDismissDlg(hwnd&, controlSelection%)
  65.       ELSE
  66.       '|
  67.       '| Obtain entryfield values for frame window width and height
  68.       '|
  69.         xbool% = WinQueryDlgItemShort(_
  70.                           hwnd&,_
  71.                           XENTRYFIELD,_
  72.                           MakeLong(VARSEG(newXFrame%), VARPTR(newXFrame%)),_
  73.                           1)
  74.         ybool% = WinQueryDlgItemShort(_
  75.                           hwnd&,_
  76.                           YENTRYFIELD,_
  77.                           MakeLong(VARSEG(newYFrame%), VARPTR(newYFrame%)),_
  78.                           1)
  79.       '|
  80.       '| Determine if width and height values are valid.  If not display
  81.       '| message to prompt user, and give valid range for both width and height
  82.       '|                  
  83.         IF (xbool% = 0 OR ybool% = 0) OR_
  84.            (newXFrame% < minFrame% OR newXFrame% > cxScreen%) OR_
  85.            (newYFrame% < minFrame% OR newYFrame% > cyScreen%) THEN
  86.              message$ = "Ivalid value or, Width or Heigth is out of "+_
  87.                         "range.  Values must be within the following ranges:"+_
  88.                         CHR$(13)+CHR$(10)+"Width:" + STR$(minFrame%)+_
  89.                         " to"+STR$(cxScreen%)+_
  90.                         CHR$(13)+CHR$(10)+"Height:" + STR$(minFrame%)+_
  91.                         " to"+STR$(cyScreen%)+CHR$(0)
  92.              caption$ = CHR$(0)
  93.              bool% = DisplayMessageBox%(message$, caption$, 2)
  94.         ELSE
  95.         '|
  96.         '| If values for frame window width and height are valid, dismiss
  97.         '| dialog box and return ID of button selected to CALLing routine
  98.         '|
  99.           bool% = WinDismissDlg(hwnd&, controlSelection%)
  100.         END IF
  101.       END IF
  102.       ClientWndProc1& = 0
  103.   '|
  104.   '| Control horizontal (Width) scroll bar
  105.   '|
  106.     CASE WMHSCROLL
  107.       CALL BreakLong(mp2&, hcommand%, lowword%)
  108.       SELECT CASE hcommand%
  109.         CASE SBLINELEFT
  110.          newXFrame% = newXFrame% - 1
  111.         CASE SBPAGELEFT
  112.          newXFrame% = newXFrame% - 10
  113.         CASE SBLINERIGHT
  114.          newXFrame% = newXFrame% + 1
  115.         CASE SBPAGERIGHT
  116.          newXFrame% = newXFrame% + 10
  117.         CASE SBSLIDERTRACK
  118.          newXFrame% = lowword%
  119.         CASE ELSE
  120.       END SELECT
  121.     '|
  122.     '| If width or height value is outside range due to a PAGELEFT or PAGERIGHT
  123.     '| set to minimum or maximum value.
  124.     '|
  125.       IF newXFrame% > cxScreen% THEN newXFrame% = cxScreen%
  126.       IF newXFrame% < minFrame% THEN newXFrame% = minFrame%
  127.     '|
  128.     '| Reset Scroll bar position indicator only if user is not sliding the
  129.     '| position indicator.
  130.     '|
  131.       IF hcommand% <> SBSLIDERTRACK THEN
  132.         bool& = WinSendDlgItemMsg(hwnd&, XSCROLLBAR,_
  133.                                   SBMSETPOS,_
  134.                                   newXFrame%,_
  135.                                   0)
  136.       END IF
  137.     '|
  138.     '| Set entry field to new value
  139.     '|
  140.       bool% = WinSetDlgItemShort(hwnd&,_
  141.                                  XENTRYFIELD,_
  142.                                  newXFrame%,_
  143.                                  1)
  144.       ClientWndProc1& = 0
  145.   '|
  146.   '| Control vertical (Height) scroll bar
  147.   '|
  148.     CASE WMVSCROLL
  149.       CALL BreakLong(mp2&, hcommand%, lowword%)
  150.       SELECT CASE hcommand%
  151.         CASE SBLINEUP
  152.           newYFrame% = newYFrame% - 1
  153.         CASE SBPAGEUP
  154.           newYFrame% = newYFrame% - 10
  155.         CASE SBLINEDOWN
  156.           newYFrame% = newYFrame% + 1
  157.         CASE SBPAGEDOWN
  158.           newYFrame% = newYFrame% + 10
  159.         CASE SBSLIDERTRACK
  160.           newYFrame% = lowword%
  161.         CASE ELSE
  162.       END SELECT
  163.     '|
  164.     '| If width or height value is outside range due to a PAGEDOWN or PAGEUP
  165.     '| set to minimum or maximum value.
  166.     '|      
  167.       IF newYFrame% > cyScreen% THEN newYFrame% = cyScreen%
  168.       IF newYFrame% < minFrame% THEN newYFrame% = minFrame%
  169.     '|
  170.     '| Reset Scroll bar position indicator only if user is not sliding the
  171.     '| position indicator.
  172.     '|      
  173.       IF hcommand% <> SBSLIDERTRACK THEN
  174.         bool& = WinSendDlgItemMsg(hwnd&, YSCROLLBAR,_
  175.                                   SBMSETPOS,_
  176.                                   newYFrame%,_
  177.                                   0)
  178.       END IF
  179.     '|
  180.     '| Set entry field to new value
  181.     '|
  182.       bool% = WinSetDlgItemShort(hwnd&,_
  183.                                  YENTRYFIELD,_
  184.                                  newYFrame%,_
  185.                                  1)
  186.       ClientWndProc1& = 0
  187.  
  188.     CASE ELSE
  189.       ClientWndProc1& = WinDefDlgProc(hwnd&, msg%, mp1&, mp2&)
  190.   END SELECT
  191. END FUNCTION
  192.  
  193.