home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pc3270sa.zip / vbdde / vbdde.bas < prev    next >
BASIC Source File  |  2002-02-28  |  9KB  |  255 lines

  1. Attribute VB_Name = "VBDDE1"
  2. Declare Function GetSystemMetrics Lib "User32" (ByVal n As Integer) As Integer
  3. Global Const SM_CXVSCROLL = 2
  4.  
  5. Global SavedSessionInfo(26) As Boolean
  6.  
  7. Global LogData$(0 To 99)
  8. Global TempData$(0 To 12)
  9. Global LogTop           As Integer
  10. Global LogEnd           As Integer
  11. Global Loged            As Integer
  12. Global FunctionComp     As Integer
  13.  
  14. Global Const MAXLOGNUM = 99
  15. Global Const CHECKED = 1
  16. Global Const UNCHECKED = 0
  17.  
  18. Global Const NONE = 0
  19. Global Const HOT = 1
  20. Global Const COLD = 2
  21.  
  22. Global Const ST_OK = -1
  23. Global Const ST_ERROR = 0
  24.  
  25. Global Const APPLICATION_NAME = "IBM327032" ' or "IBM525032"
  26.  
  27. Global MSG_SAMPLE_PROG As String
  28. Global MSG_APPLICATION As String
  29. Global MSG_TOPIC As String
  30. Global MSG_ITEM As String
  31. Global MSG_FUNCTION_COMP As String
  32. Global MSG_DDE_ERROR As String
  33. Global MSG_PARA_ERROR As String
  34. Global MSG_INVALID_DATA As String
  35. Global MSG_OK As String
  36. Global MSG_NG As String
  37. Global MSG_INVALID_PSID As String
  38.  
  39. Global Const cdlOFNReadOnly = &H1             'Checks Read-Only check box for Open and Save As dialog boxes.
  40. Global Const cdlOFNOverwritePrompt = &H2      'Causes the Save As dialog box to generate a message box if the selected file already exists.
  41. Global Const cdlOFNHideReadOnly = &H4         'Hides the Read-Only check box.
  42. Global Const cdlOFNNoChangeDir = &H8          'Sets the current directory to what it was when the dialog box was invoked.
  43. Global Const cdlOFNHelpButton = &H10          'Causes the dialog box to display the Help button.
  44. Global Const cdlOFNNoValidate = &H100         'Allows invalid characters in the returned filename.
  45. Global Const cdlOFNAllowMultiselect = &H200   'Allows the File Name list box to have multiple selections.
  46. Global Const cdlOFNExtensionDifferent = &H400 'The extension of the returned filename is different from the extension set by the DefaultExt property.
  47.  
  48. Global Const cdlOFNPathMustExist = &H800   'User can enter only valid path names.
  49. Global Const cdlOFNFileMustExist = &H1000  'User can enter only names of existing files.
  50. Global Const cdlOFNCreatePrompt = &H2000   'Sets the dialog box to ask if the user wants to create a file that doesn't currently exist.
  51. Global Const cdlOFNShareAware = &H4000     'Sharing violation errors will be ignored.
  52. Global Const cdlOFNNoReadOnlyReturn = &H8000  'The returned file doesn't have the Read-Only attribute set and won't be in a write-protected directory.
  53. Global Const cdlOFNExplorer = &H8000       'Use the Explorer-like Open A File dialog box template.  (Windows 95 only.)
  54. Global Const cdlOFNNoDereferenceLinks = &H100000       'Do not dereference shortcuts (shell links).  By default, choosing a shortcut causes it to be dereferenced by the shell.  (Windows 95 only.)
  55.  
  56. Global Const cdlOFNLongNames = &H200000               'Use Long filenames.  (Windows 95 only.)
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65. Public Function GetDisplayType(SessionId As String) As String
  66. On Error GoTo ErrHandler
  67.    FunctionComp = True
  68.  
  69.    GetDisplayType$ = "NONE"
  70.    
  71.    rc = DoEvents()              'If you use VisualBasic V2.0, call
  72.                                 'DoEvents function each time before
  73.                                 'starting DDE conversation.
  74.    MainForm.GetDisplayTypeText.LinkTimeout = 50  ' Wait 5 seconds
  75.    MainForm.GetDisplayTypeText.LinkTopic = "IBM327032|System"
  76.    MainForm.GetDisplayTypeText.LinkMode = COLD
  77.    MainForm.GetDisplayTypeText.LinkItem = "Status"
  78.    MainForm.GetDisplayTypeText.LinkRequest
  79.    MainForm.GetDisplayTypeText.LinkMode = NONE
  80.    If FunctionComp = True Then
  81.       AllSessionInfo$ = MainForm.GetDisplayTypeText.Text
  82.       
  83.       NLCR$ = Chr$(13) + Chr$(10)
  84.       ' There are at most 26 sessions.
  85.       For LineCount = 1 To 26
  86.         If (Mid$(AllSessionInfo$, 1, 1) = SessionId) Then
  87.  
  88.           BeginningOfField = 0
  89.           EndOfField = 0
  90.           For Index = 1 To 3
  91.             BeginningOfField = BeginningOfField + EndOfField + 1
  92.             EndOfField = InStr(Mid$(AllSessionInfo$, BeginningOfField), Chr$(9))
  93.           Next Index
  94.           
  95.           ReturnString$ = Mid$(AllSessionInfo$, BeginningOfField, EndOfField - 1)
  96.           GetDisplayType$ = Left$(ReturnString$, 4)
  97.           Exit For
  98.         Else
  99.           EndOfLine = InStr(1, AllSessionInfo$, NLCR$)
  100.         
  101.           If EndOfLine = 0 Then
  102.             ' No more lines.
  103.             Exit For
  104.           Else
  105.             ' Found NLCR.
  106.             AllSessionInfo$ = Mid$(AllSessionInfo$, EndOfLine + 2)
  107.             ' Just in case the last line has a NLCR in the future.
  108.             If AllSessionInfo$ = "" Then
  109.               Exit For
  110.             End If
  111.           End If
  112.         End If
  113.       Next LineCount
  114.    End If
  115.    Exit Function
  116.  
  117. ErrHandler:
  118.    FunctionComp = False
  119.    Resume Next
  120.  
  121. End Function
  122.  
  123. Public Sub GetSessionDimensions(SessionId As String, Width As Integer, Height As Integer)
  124. On Error GoTo ErrHandler
  125.    FunctionComp = True
  126.    Width = 0
  127.    Height = 0
  128.  
  129.    Topic$ = "Session" + SessionId
  130.    Item$ = "SSTAT"
  131.    
  132.    rc = DoEvents()              'If you use VisualBasic V2.0, call
  133.                                 'DoEvents function each time before
  134.                                 'starting DDE conversation.
  135.    MainForm.SessionDimensionsTextBox.LinkTimeout = -1
  136.    MainForm.SessionDimensionsTextBox.LinkTopic = APPLICATION_NAME + "|" + Topic$
  137.    MainForm.SessionDimensionsTextBox.LinkMode = COLD
  138.    MainForm.SessionDimensionsTextBox.LinkItem = Item$
  139.    MainForm.SessionDimensionsTextBox.LinkRequest
  140.    MainForm.SessionDimensionsTextBox.LinkMode = NONE
  141.  
  142.    If FunctionComp = True Then
  143.      StartPos& = 1
  144.      EndPos& = 1
  145.      StringLength& = Len(MainForm.SessionDimensionsTextBox.Text)
  146.      For i% = 0 To 3
  147.        EndPos& = InStr(StartPos&, MainForm.SessionDimensionsTextBox.Text, Chr$(9))
  148.        If EndPos& = 0 Then
  149.          Width = 0
  150.          Height = 0
  151.          Exit Sub
  152.        End If
  153.        If i% = 2 Then
  154.          Width = LTrim$(RTrim$(Mid$(MainForm.SessionDimensionsTextBox.Text, StartPos&, EndPos& - StartPos&)))
  155.        ElseIf i% = 3 Then
  156.          Height = LTrim$(RTrim$(Mid$(MainForm.SessionDimensionsTextBox.Text, StartPos&, EndPos& - StartPos&)))
  157.        End If
  158.        StartPos& = EndPos& + 1
  159.      Next i%
  160.    End If
  161. Exit Sub
  162.  
  163. ErrHandler:
  164.    FunctionComp = False
  165.    Resume Next
  166. End Sub
  167.  
  168. Public Sub CleanUpNumberText(NumberText As TextBox)
  169. Dim NumericalValue As Integer
  170.  
  171.   InsertionPoint = NumberText.SelStart
  172.   temp$ = NumberText.Text
  173.   For Counter = 1 To Len(NumberText.Text)
  174.     If InStr("0123456789", Mid(temp$, Counter, 1)) = 0 Then
  175.       Mid(temp$, Counter, 1) = "0"
  176.     End If
  177.   Next Counter
  178.   NumberText.Text = temp$
  179.   NumberText.SelStart = InsertionPoint
  180.  
  181. End Sub
  182.  
  183.  
  184.  
  185. Public Function GetTrimRectangleCoords(SessionId As String, TopLeftColumn, TopLeftRow, BottomRightColumn, BottomRightRow) As String
  186. On Error GoTo ErrHandler
  187.    FunctionComp = True
  188.    
  189.    GetTrimRectangleCoords = "Closed"
  190.    TopLeftColumn = 0
  191.    TopLeftRow = 0
  192.    BottomRightColumn = 0
  193.    BottomRightRow = 0
  194.  
  195.    Topic$ = "Session" + SessionId
  196.    Item$ = "SSTAT"
  197.    
  198.    rc = DoEvents()              'If you use VisualBasic V2.0, call
  199.                                 'DoEvents function each time before
  200.                                 'starting DDE conversation.
  201.    MainForm.SessionCoordsTextBox.LinkTimeout = -1
  202.    MainForm.SessionCoordsTextBox.LinkTopic = APPLICATION_NAME + "|" + Topic$
  203.    MainForm.SessionCoordsTextBox.LinkMode = COLD
  204.    MainForm.SessionCoordsTextBox.LinkItem = Item$
  205.    MainForm.SessionCoordsTextBox.LinkRequest
  206.    MainForm.SessionCoordsTextBox.LinkMode = NONE
  207.  
  208.    If FunctionComp = True Then
  209.      StartPos& = 1
  210.      EndPos& = 1
  211.      StringLength& = Len(MainForm.SessionCoordsTextBox.Text)
  212.      For i% = 0 To 10
  213.        EndPos& = InStr(StartPos&, MainForm.SessionCoordsTextBox.Text, Chr$(9))
  214.        If EndPos& = 0 Then
  215.          GetTrimRectangleCoords = "Closed"
  216.          Exit Function
  217.        End If
  218.        
  219.        If (i% >= 6) And (i% <= 10) Then
  220.          If i% = 6 Then
  221.            GetTrimRectangleCoords = LTrim$(RTrim$(Mid$(MainForm.SessionCoordsTextBox.Text, StartPos&, EndPos& - StartPos&)))
  222.          ElseIf i% = 7 Then
  223.            TopLeftColumn = LTrim$(RTrim$(Mid$(MainForm.SessionCoordsTextBox.Text, StartPos&, EndPos& - StartPos&)))
  224.          ElseIf i% = 8 Then
  225.            TopLeftRow = LTrim$(RTrim$(Mid$(MainForm.SessionCoordsTextBox.Text, StartPos&, EndPos& - StartPos&)))
  226.          ElseIf i% = 9 Then
  227.            BottomRightColumn = LTrim$(RTrim$(Mid$(MainForm.SessionCoordsTextBox.Text, StartPos&, EndPos& - StartPos&)))
  228.          ElseIf i% = 10 Then
  229.            BottomRightRow = LTrim$(RTrim$(Mid$(MainForm.SessionCoordsTextBox.Text, StartPos&, EndPos& - StartPos&)))
  230.          End If
  231.        End If
  232.        StartPos& = EndPos& + 1
  233.      Next i%
  234.    End If
  235. Exit Function
  236.  
  237. ErrHandler:
  238.    FunctionComp = False
  239.    Resume Next
  240. End Function
  241.  
  242. Public Sub AdjustForNT351(FormToAdjust As Form)
  243.  
  244.   For Each IndexControl In FormToAdjust.Controls()
  245.     If TypeOf IndexControl Is TextBox Then
  246.       If IndexControl.ScrollBars = 1 Then ' if Horizontal ScrollBar
  247.         IndexControl.Height = IndexControl.Height + 120 ' Flat
  248.         IndexControl.Top = IndexControl.Top - 30 ' Flat
  249.       End If
  250.     End If
  251.   Next IndexControl
  252. End Sub
  253.  
  254.  
  255.