home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pc3270sa.zip / vbdde / fsttrmad.frm < prev    next >
Text File  |  2002-02-28  |  17KB  |  536 lines

  1. VERSION 4.00
  2. Begin VB.Form FormStartTrimRectAdvise 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Start Session Advise (Trim Rect)"
  5.    ClientHeight    =   6624
  6.    ClientLeft      =   2472
  7.    ClientTop       =   1752
  8.    ClientWidth     =   6984
  9.    ControlBox      =   0   'False
  10.    BeginProperty Font 
  11.       name            =   "MS Sans Serif"
  12.       charset         =   0
  13.       weight          =   700
  14.       size            =   7.8
  15.       underline       =   0   'False
  16.       italic          =   0   'False
  17.       strikethrough   =   0   'False
  18.    EndProperty
  19.    ForeColor       =   &H80000008&
  20.    Height          =   6948
  21.    Left            =   2424
  22.    LinkMode        =   1  'Source
  23.    LinkTopic       =   "Form1"
  24.    MaxButton       =   0   'False
  25.    MinButton       =   0   'False
  26.    ScaleHeight     =   6624
  27.    ScaleWidth      =   6984
  28.    ShowInTaskbar   =   0   'False
  29.    Top             =   1476
  30.    Width           =   7080
  31.    Begin VB.TextBox TrimDataText 
  32.       BackColor       =   &H00C0FFFF&
  33.       BeginProperty Font 
  34.          name            =   "IBM3270"
  35.          charset         =   0
  36.          weight          =   400
  37.          size            =   9.6
  38.          underline       =   0   'False
  39.          italic          =   0   'False
  40.          strikethrough   =   0   'False
  41.       EndProperty
  42.       ForeColor       =   &H00FF0000&
  43.       Height          =   2772
  44.       Left            =   240
  45.       Locked          =   -1  'True
  46.       MousePointer    =   1  'Arrow
  47.       MultiLine       =   -1  'True
  48.       ScrollBars      =   3  'Both
  49.       TabIndex        =   21
  50.       TabStop         =   0   'False
  51.       Top             =   3120
  52.       Width           =   6492
  53.    End
  54.    Begin VB.Frame Frame2 
  55.       Caption         =   "Trim Rectangle Data"
  56.       Height          =   3132
  57.       Left            =   120
  58.       TabIndex        =   23
  59.       Top             =   2880
  60.       Width           =   6732
  61.    End
  62.    Begin VB.ComboBox SessionIdList 
  63.       BackColor       =   &H00FFFFC0&
  64.       ForeColor       =   &H00000000&
  65.       Height          =   288
  66.       ItemData        =   "FSTTRMAD.frx":0000
  67.       Left            =   1200
  68.       List            =   "FSTTRMAD.frx":0052
  69.       Sorted          =   -1  'True
  70.       Style           =   2  'Dropdown List
  71.       TabIndex        =   2
  72.       Top             =   360
  73.       Width           =   492
  74.    End
  75.    Begin VB.CommandButton ExitCommand 
  76.       Cancel          =   -1  'True
  77.       Caption         =   "E&xit"
  78.       Height          =   372
  79.       Left            =   4680
  80.       TabIndex        =   20
  81.       Top             =   6120
  82.       Width           =   852
  83.    End
  84.    Begin VB.CommandButton StopCommand 
  85.       Caption         =   "&End"
  86.       Enabled         =   0   'False
  87.       Height          =   372
  88.       Left            =   3000
  89.       TabIndex        =   19
  90.       Top             =   6120
  91.       Width           =   876
  92.    End
  93.    Begin VB.CommandButton StartCommand 
  94.       Caption         =   "&Begin"
  95.       Default         =   -1  'True
  96.       Height          =   372
  97.       Left            =   1320
  98.       TabIndex        =   18
  99.       Top             =   6120
  100.       Width           =   876
  101.    End
  102.    Begin VB.Frame TrimFrame 
  103.       Enabled         =   0   'False
  104.       ForeColor       =   &H80000008&
  105.       Height          =   1212
  106.       Left            =   2880
  107.       TabIndex        =   7
  108.       Top             =   1080
  109.       Width           =   3732
  110.       Begin VB.TextBox TrimLRColumnText 
  111.          BackColor       =   &H00FFFFC0&
  112.          Enabled         =   0   'False
  113.          ForeColor       =   &H00404040&
  114.          Height          =   288
  115.          Left            =   2952
  116.          MaxLength       =   3
  117.          TabIndex        =   17
  118.          Text            =   "80"
  119.          Top             =   840
  120.          Width           =   420
  121.       End
  122.       Begin VB.TextBox TrimLRRowText 
  123.          BackColor       =   &H00FFFFC0&
  124.          Enabled         =   0   'False
  125.          ForeColor       =   &H00000000&
  126.          Height          =   288
  127.          Left            =   2952
  128.          MaxLength       =   3
  129.          TabIndex        =   15
  130.          Text            =   "24"
  131.          Top             =   480
  132.          Width           =   420
  133.       End
  134.       Begin VB.TextBox TrimTLColumnText 
  135.          BackColor       =   &H00FFFFC0&
  136.          Enabled         =   0   'False
  137.          ForeColor       =   &H00000000&
  138.          Height          =   288
  139.          Left            =   1152
  140.          MaxLength       =   3
  141.          TabIndex        =   12
  142.          Text            =   "1"
  143.          Top             =   840
  144.          Width           =   420
  145.       End
  146.       Begin VB.TextBox TrimTLRowText 
  147.          BackColor       =   &H00FFFFC0&
  148.          Enabled         =   0   'False
  149.          ForeColor       =   &H00000000&
  150.          Height          =   288
  151.          Left            =   1152
  152.          MaxLength       =   3
  153.          TabIndex        =   10
  154.          Text            =   "1"
  155.          Top             =   480
  156.          Width           =   420
  157.       End
  158.       Begin VB.Label TrimLabel6 
  159.          Caption         =   "Column"
  160.          Enabled         =   0   'False
  161.          ForeColor       =   &H80000008&
  162.          Height          =   252
  163.          Left            =   2040
  164.          TabIndex        =   16
  165.          Top             =   840
  166.          Width           =   852
  167.       End
  168.       Begin VB.Label TrimLabel5 
  169.          Caption         =   "Row"
  170.          Enabled         =   0   'False
  171.          ForeColor       =   &H80000008&
  172.          Height          =   252
  173.          Left            =   2040
  174.          TabIndex        =   14
  175.          Top             =   480
  176.          Width           =   852
  177.       End
  178.       Begin VB.Label TrimLabel4 
  179.          Caption         =   "&Lower right corner"
  180.          Enabled         =   0   'False
  181.          ForeColor       =   &H80000008&
  182.          Height          =   252
  183.          Left            =   1992
  184.          TabIndex        =   13
  185.          Top             =   240
  186.          Width           =   1644
  187.       End
  188.       Begin VB.Label TrimLabel3 
  189.          Caption         =   "Column"
  190.          Enabled         =   0   'False
  191.          ForeColor       =   &H80000008&
  192.          Height          =   252
  193.          Left            =   240
  194.          TabIndex        =   11
  195.          Top             =   840
  196.          Width           =   852
  197.       End
  198.       Begin VB.Label TrimLabel2 
  199.          Caption         =   "Row"
  200.          Enabled         =   0   'False
  201.          ForeColor       =   &H80000008&
  202.          Height          =   252
  203.          Left            =   240
  204.          TabIndex        =   9
  205.          Top             =   480
  206.          Width           =   852
  207.       End
  208.       Begin VB.Label TrimLabel1 
  209.          Caption         =   "&Top left corner"
  210.          Enabled         =   0   'False
  211.          ForeColor       =   &H80000008&
  212.          Height          =   252
  213.          Left            =   192
  214.          TabIndex        =   8
  215.          Top             =   240
  216.          Width           =   1452
  217.       End
  218.    End
  219.    Begin VB.CheckBox TrimCheck 
  220.       Caption         =   "&SpecifyTrim Rectangle"
  221.       ForeColor       =   &H80000008&
  222.       Height          =   375
  223.       Left            =   2880
  224.       TabIndex        =   6
  225.       Top             =   720
  226.       Width           =   2175
  227.    End
  228.    Begin VB.Frame UserDefFrame 
  229.       Caption         =   "User &Defined String"
  230.       Enabled         =   0   'False
  231.       ForeColor       =   &H80000008&
  232.       Height          =   612
  233.       Left            =   240
  234.       TabIndex        =   4
  235.       Top             =   1080
  236.       Width           =   2412
  237.       Begin VB.TextBox UserDefStrText 
  238.          BackColor       =   &H00FFFFC0&
  239.          Enabled         =   0   'False
  240.          ForeColor       =   &H00000000&
  241.          Height          =   288
  242.          Left            =   120
  243.          TabIndex        =   5
  244.          Text            =   "example"
  245.          Top             =   240
  246.          Width           =   2172
  247.       End
  248.    End
  249.    Begin VB.CheckBox TopicCheck 
  250.       Caption         =   "&Use Session Topic Name "
  251.       ForeColor       =   &H80000008&
  252.       Height          =   375
  253.       Left            =   240
  254.       TabIndex        =   3
  255.       Top             =   720
  256.       Value           =   1  'Checked
  257.       Width           =   2535
  258.    End
  259.    Begin VB.Frame Frame1 
  260.       Caption         =   "Input Parameters"
  261.       Height          =   2412
  262.       Left            =   120
  263.       TabIndex        =   0
  264.       Top             =   120
  265.       Width           =   6612
  266.       Begin VB.Frame Frame3 
  267.          Caption         =   "Topic"
  268.          Height          =   612
  269.          Left            =   120
  270.          TabIndex        =   24
  271.          Top             =   1680
  272.          Width           =   2412
  273.          Begin VB.Label TopicLabel 
  274.             Alignment       =   2  'Center
  275.             Caption         =   "SessionA"
  276.             Height          =   252
  277.             Left            =   120
  278.             TabIndex        =   25
  279.             Top             =   240
  280.             Width           =   2172
  281.          End
  282.       End
  283.       Begin VB.Label Label2 
  284.          Caption         =   "Session &Id"
  285.          Height          =   252
  286.          Left            =   120
  287.          TabIndex        =   1
  288.          Top             =   240
  289.          Width           =   972
  290.       End
  291.    End
  292.    Begin VB.Label ResultMessageLabel 
  293.       Alignment       =   2  'Center
  294.       Caption         =   "DDE Conversation Started"
  295.       ForeColor       =   &H00FF0000&
  296.       Height          =   252
  297.       Left            =   120
  298.       TabIndex        =   22
  299.       Top             =   2640
  300.       Visible         =   0   'False
  301.       Width           =   6612
  302.    End
  303. End
  304. Attribute VB_Name = "FormStartTrimRectAdvise"
  305. Attribute VB_Creatable = False
  306. Attribute VB_Exposed = False
  307.  
  308. Private Sub ChangeTrimGroup(Status As Integer)
  309.    TrimFrame.Enabled = Status
  310.    TrimLabel1.Enabled = Status
  311.    TrimLabel2.Enabled = Status
  312.    TrimLabel3.Enabled = Status
  313.    TrimLabel4.Enabled = Status
  314.    TrimLabel5.Enabled = Status
  315.    TrimLabel6.Enabled = Status
  316.    TrimTLRowText.Enabled = Status
  317.    TrimTLColumnText.Enabled = Status
  318.    TrimLRRowText.Enabled = Status
  319.    TrimLRColumnText.Enabled = Status
  320. End Sub
  321.  
  322. Private Sub ExitCommand_Click()
  323.    Unload FormStartTrimRectAdvise
  324. End Sub
  325.  
  326. Private Function GetTopicName() As String
  327.  
  328.    If Len(SessionIdList.Text) > 0 Then
  329.       If TopicCheck.Value = CHECKED Then
  330.          ReturnString$ = "Session" + SessionIdList.Text
  331.       Else
  332.          ReturnString$ = "Sess" + SessionIdList.Text + "_" + UserDefStrText.Text
  333.       End If
  334.       GetTopicName = ReturnString$
  335.    Else
  336.       MsgBox MSG_PARA_ERROR, 48, MSG_SAMPLE_PROG
  337.    End If
  338. End Function
  339.  
  340. Private Function GetTrimItemName() As String
  341.    Dim TopLeftRow As String
  342.    Dim TopLeftCol As String
  343.    Dim LowRightRow As String
  344.    Dim LowRightCol As String
  345.    Dim ReturnString As String
  346.    Dim FuncStatus As Integer
  347.    FuncStatus = ST_OK
  348.  
  349.    ReturnString = "TRIMRECT"
  350.    If TrimCheck.Value = CHECKED Then
  351.       TopLeftRow = RTrim$(LTrim$(TrimTLRowText.Text))
  352.       TopLeftCol = RTrim$(LTrim$(TrimTLColumnText.Text))
  353.       LowRightRow = RTrim$(LTrim$(TrimLRRowText.Text))
  354.       LowRightCol = RTrim$(LTrim$(TrimLRColumnText.Text))
  355.       If (Len(TopLeftRow) > 0) And (Len(TopLeftCol) > 0) And (Len(LowRightRow) > 0) And (Len(LowRightCol) > 0) Then
  356.          ReturnString = ReturnString + "(" + TopLeftRow + "," + TopLeftCol + "," + LowRightRow + "," + LowRightCol + ")"
  357.       Else
  358.          MsgBox MSG_PARA_ERROR, 48, MSG_SAMPLE_PROG
  359.          FuncStatus = ST_ERROR
  360.       End If
  361.    End If
  362.    If FuncStatus = ST_OK Then
  363.       GetTrimItemName = ReturnString
  364.    End If
  365. End Function
  366.  
  367. Private Sub Form_Load()
  368.   SessionIdList.ListIndex = 0
  369. End Sub
  370.  
  371. Private Sub StartCommand_Click()
  372. On Error GoTo ErrHandler
  373.    FunctionComp = True
  374.    
  375.    OldMousePointer = MousePointer
  376.    MousePointer = 11 ' Hour Glass Mouse Pointer
  377.    
  378.    DisplayType$ = GetDisplayType$(SessionIdList.Text)
  379.    
  380.    If DisplayType$ = "NONE" Then
  381.       MousePointer = OldMousePointer
  382.       MsgBox MSG_INVALID_PSID + SessionIdList.Text, 48, MSG_SAMPLE_PROG
  383.       Exit Sub
  384.    End If
  385.    
  386.    If TrimCheck.Value = 0 Then
  387.      If GetTrimRectangleCoords(SessionIdList.Text, TLCol, TLRow, BRCol, BRRow) = "Closed" Then
  388.        MousePointer = OldMousePointer
  389.        MsgBox "Either" & Chr$(13) & Chr$(10) & Chr$(9) & "1) specify Trim Rectangle on this form" & Chr$(13) & Chr$(10) & "or" & Chr$(9) & " 2) select Trim Rectangle on session."
  390.        Exit Sub
  391.      End If
  392.    End If
  393.    
  394.    Topic$ = GetTopicName()
  395.    If Len(Topic$) <= 0 Then
  396.       MsgBox MSG_PARA_ERROR, 48, MSG_SAMPLE_PROG
  397.       MousePointer = OldMousePointer
  398.       Exit Sub
  399.    End If
  400.    
  401.    Item$ = GetTrimItemName()
  402.    If Len(Item$) <= 0 Then
  403.       MsgBox MSG_PARA_ERROR, 48, MSG_SAMPLE_PROG
  404.       MousePointer = OldMousePointer
  405.       Exit Sub
  406.    End If
  407.    
  408.          rc = DoEvents()        'If you use VisualBasic V2.0, call
  409.                                 'DoEvents function each time before
  410.                                 'starting DDE conversation.
  411.          TrimDataText.LinkTimeout = -1
  412.          TrimDataText.LinkTopic = APPLICATION_NAME + "|" + Topic$
  413.          TrimDataText.LinkItem = Item$
  414.          TrimDataText.LinkMode = HOT
  415.          
  416.       MousePointer = OldMousePointer
  417.          If FunctionComp = True Then
  418.             ResultMessageLabel.Visible = True
  419.             EndStatus$ = MSG_OK
  420.             StartCommand.Enabled = False
  421.             StopCommand.Enabled = True
  422.             ExitCommand.Enabled = False
  423.          Else
  424.             ResultMessageLabel.Visible = False
  425.             MsgBox MSG_DDE_ERROR, 48, MSG_SAMPLE_PROG
  426.             EndStatus$ = MSG_NG
  427.          End If
  428.          TempLogData$ = Time$ + ":Start Session Advise (TrimRect) : " + EndStatus$ + Chr$(13) + Chr$(10) + Chr$(9)
  429.          TempLogData$ = TempLogData$ + MSG_APPLICATION + APPLICATION_NAME + """" + Chr$(13) + Chr$(10) + Chr$(9)
  430.          TempLogData$ = TempLogData$ + MSG_TOPIC + """" + Topic$ + """" + Chr$(13) + Chr$(10) + Chr$(9)
  431.          TempLogData$ = TempLogData$ + MSG_ITEM + """" + Item$ + """" + Chr$(13) + Chr$(10)
  432.          LogData$(LogEnd) = TempLogData$
  433.          UpdateLogPointer
  434.          UpdateLog
  435.    Exit Sub
  436.  
  437. ErrHandler:
  438.    FunctionComp = False
  439.    Resume Next
  440. End Sub
  441.  
  442. Private Sub StopCommand_Click()
  443. On Error GoTo StopErrHandler
  444.    FunctionComp = True
  445.    
  446.    TrimDataText.LinkTimeout = -1
  447.    TrimDataText.LinkMode = NONE
  448.    If FunctionComp = True Then
  449.       ResultMessageLabel.Visible = False
  450.       EndStatus$ = MSG_OK
  451.       StopCommand.Enabled = False
  452.       StartCommand.Enabled = True
  453.       ExitCommand.Enabled = True
  454.    Else
  455.       MsgBox MSG_DDE_ERROR, 48, MSG_SAMPLE_PROG
  456.       EndStatus$ = MSG_NG
  457.    End If
  458.    LogData$(LogEnd) = Time$ + ":Stop Session Advise (TrimRect) : " + EndStatus$ + Chr$(13) + Chr$(10)
  459.    UpdateLogPointer
  460.    UpdateLog
  461.    Exit Sub
  462.  
  463. StopErrHandler:
  464.    FunctionComp = False
  465.    Resume Next
  466. End Sub
  467.  
  468. Private Sub TopicCheck_Click()
  469.   If TopicCheck.Value = CHECKED Then
  470.      UserDefFrame.Enabled = False
  471.      UserDefStrText.Enabled = False
  472.   Else
  473.      UserDefFrame.Enabled = True
  474.      UserDefStrText.Enabled = True
  475.   End If
  476.   
  477.   TopicLabel.Caption = GetTopicName()
  478. End Sub
  479.  
  480. Private Sub TrimCheck_Click()
  481.    If TrimCheck.Value = CHECKED Then
  482.        ChangeTrimGroup (True)
  483.    Else
  484.        ChangeTrimGroup (False)
  485.    End If
  486. End Sub
  487.  
  488. Private Sub TrimDataText_Change()
  489.    If StartCommand.Enabled = False Then
  490.       LogData$(LogEnd) = Time$ + ":Trim Rect was updated :" + Chr$(13) + Chr$(10)
  491.       UpdateLogPointer
  492.       UpdateLog
  493.    End If
  494.  
  495. End Sub
  496.  
  497. Private Sub UpdateLog()
  498.     temp$ = " "
  499.     If LogTop > LogEnd Then
  500.        For i% = LogTop To MAXLOGNUM
  501.           temp$ = temp$ + LogData$(i%)
  502.        Next
  503.        For i% = 0 To LogEnd
  504.           temp$ = temp$ + LogData$(i%)
  505.        Next
  506.     ElseIf LogTop < LogEnd Then
  507.        For i% = LogTop To LogEnd
  508.           temp$ = temp$ + LogData(i%)
  509.        Next
  510.     Else
  511.        temp$ = LogData(i%)
  512.     End If
  513.     MainForm.FunctionLog.Text = temp$
  514.     Loged = False
  515. End Sub
  516.  
  517. Private Sub UpdateLogPointer()
  518.     LogEnd = LogEnd + 1
  519.     If LogEnd = MAXLOGNUM + 1 Then
  520.        LogEnd = 0
  521.     End If
  522.  
  523.     If LogTop = LogEnd Then
  524.        LogTop = LogTop + 1
  525.        If LogTop = MAXLOGNUM + 1 Then
  526.           LogTop = 0
  527.        End If
  528.     End If
  529. End Sub
  530.  
  531. Private Sub UserDefStrText_Change()
  532.   TopicLabel.Caption = GetTopicName()
  533. End Sub
  534.  
  535.  
  536.