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

  1. VERSION 4.00
  2. Begin VB.Form FormStartKeystrokeIntercept 
  3.    Caption         =   "Start Keystroke Intercept"
  4.    ClientHeight    =   4092
  5.    ClientLeft      =   4236
  6.    ClientTop       =   3780
  7.    ClientWidth     =   3732
  8.    ControlBox      =   0   'False
  9.    BeginProperty Font 
  10.       name            =   "MS Sans Serif"
  11.       charset         =   0
  12.       weight          =   700
  13.       size            =   7.8
  14.       underline       =   0   'False
  15.       italic          =   0   'False
  16.       strikethrough   =   0   'False
  17.    EndProperty
  18.    ForeColor       =   &H80000008&
  19.    Height          =   4416
  20.    Left            =   4188
  21.    LinkMode        =   1  'Source
  22.    LinkTopic       =   "Form1"
  23.    ScaleHeight     =   4092
  24.    ScaleWidth      =   3732
  25.    Top             =   3504
  26.    Width           =   3828
  27.    Begin VB.Frame Frame3 
  28.       Caption         =   "Intercepted Key"
  29.       Height          =   612
  30.       Left            =   120
  31.       TabIndex        =   13
  32.       Top             =   2880
  33.       Width           =   3492
  34.       Begin VB.Label LastInterceptedKeyLabel 
  35.          Alignment       =   2  'Center
  36.          Height          =   252
  37.          Left            =   120
  38.          TabIndex        =   14
  39.          Top             =   240
  40.          Width           =   3252
  41.       End
  42.    End
  43.    Begin VB.ComboBox SessionIdList 
  44.       BackColor       =   &H00FFFFC0&
  45.       ForeColor       =   &H00000000&
  46.       Height          =   288
  47.       ItemData        =   "FSTKYINT.frx":0000
  48.       Left            =   1320
  49.       List            =   "FSTKYINT.frx":0052
  50.       Sorted          =   -1  'True
  51.       Style           =   2  'Dropdown List
  52.       TabIndex        =   2
  53.       Top             =   360
  54.       Width           =   492
  55.    End
  56.    Begin VB.CommandButton ExitCommand 
  57.       Cancel          =   -1  'True
  58.       Caption         =   "E&xit"
  59.       Height          =   372
  60.       Left            =   2640
  61.       TabIndex        =   10
  62.       Top             =   3600
  63.       Width           =   852
  64.    End
  65.    Begin VB.CommandButton StopCommand 
  66.       Caption         =   "&End"
  67.       Enabled         =   0   'False
  68.       Height          =   372
  69.       Left            =   1440
  70.       TabIndex        =   9
  71.       Top             =   3600
  72.       Width           =   852
  73.    End
  74.    Begin VB.CommandButton StartCommand 
  75.       Caption         =   "&Begin"
  76.       Default         =   -1  'True
  77.       Height          =   372
  78.       Left            =   216
  79.       TabIndex        =   8
  80.       Top             =   3600
  81.       Width           =   876
  82.    End
  83.    Begin VB.Frame UserDefFrame 
  84.       Caption         =   "User Defined &String"
  85.       Enabled         =   0   'False
  86.       ForeColor       =   &H80000008&
  87.       Height          =   612
  88.       Left            =   240
  89.       TabIndex        =   4
  90.       Top             =   1080
  91.       Width           =   3252
  92.       Begin VB.TextBox UserDefStrText 
  93.          BackColor       =   &H00FFFFC0&
  94.          Enabled         =   0   'False
  95.          ForeColor       =   &H00000000&
  96.          Height          =   288
  97.          Left            =   120
  98.          TabIndex        =   5
  99.          Text            =   "example"
  100.          Top             =   240
  101.          Width           =   2964
  102.       End
  103.    End
  104.    Begin VB.TextBox KeyInterceptText 
  105.       BackColor       =   &H00C0FFFF&
  106.       Height          =   372
  107.       Left            =   2400
  108.       TabIndex        =   11
  109.       Top             =   3600
  110.       Visible         =   0   'False
  111.       Width           =   192
  112.    End
  113.    Begin VB.CheckBox TopicCheck 
  114.       Caption         =   "&Use Session Topic Name "
  115.       ForeColor       =   &H80000008&
  116.       Height          =   372
  117.       Left            =   312
  118.       TabIndex        =   3
  119.       Top             =   720
  120.       Value           =   1  'Checked
  121.       Width           =   2508
  122.    End
  123.    Begin VB.Frame Frame1 
  124.       Caption         =   "Input Parameters"
  125.       Height          =   2412
  126.       Left            =   120
  127.       TabIndex        =   0
  128.       Top             =   120
  129.       Width           =   3492
  130.       Begin VB.Frame Frame2 
  131.          Caption         =   "Topic"
  132.          Height          =   612
  133.          Left            =   120
  134.          TabIndex        =   6
  135.          Top             =   1680
  136.          Width           =   3252
  137.          Begin VB.Label TopicLabel 
  138.             Alignment       =   2  'Center
  139.             Caption         =   "SessionA"
  140.             Height          =   252
  141.             Left            =   120
  142.             TabIndex        =   7
  143.             Top             =   240
  144.             Width           =   3012
  145.          End
  146.       End
  147.       Begin VB.Label Label1 
  148.          Caption         =   "Session &Id"
  149.          Height          =   252
  150.          Left            =   120
  151.          TabIndex        =   1
  152.          Top             =   240
  153.          Width           =   1092
  154.       End
  155.    End
  156.    Begin VB.Label ResultMessageLabel 
  157.       Alignment       =   2  'Center
  158.       Caption         =   "DDE Conversation Active"
  159.       ForeColor       =   &H00FF0000&
  160.       Height          =   252
  161.       Left            =   240
  162.       TabIndex        =   12
  163.       Top             =   2640
  164.       Visible         =   0   'False
  165.       Width           =   3276
  166.    End
  167. End
  168. Attribute VB_Name = "FormStartKeystrokeIntercept"
  169. Attribute VB_Creatable = False
  170. Attribute VB_Exposed = False
  171. Private Sub ExitCommand_Click()
  172.     Unload FormStartKeystrokeIntercept
  173. End Sub
  174.  
  175. Private Function GetTopicName() As String
  176.    If Len(SessionIdList.Text) > 0 Then
  177.       If TopicCheck.Value = CHECKED Then
  178.          ReturnString$ = "Session" + SessionIdList.Text
  179.       Else
  180.          ReturnString$ = "Sess" + SessionIdList.Text + "_" + UserDefStrText.Text
  181.       End If
  182.       GetTopicName = ReturnString$
  183.    Else
  184.       MsgBox MSG_PARA_ERROR, 48, MSG_SAMPLE_PROG
  185.    End If
  186. End Function
  187.  
  188. Private Sub Form_Load()
  189.   SessionIdList.ListIndex = 0
  190. End Sub
  191.  
  192. Private Sub KeyInterceptText_Change()
  193.  
  194.    If StartCommand.Enabled = False Then
  195.       If Len(RTrim$(LTrim$(KeyInterceptText.Text))) > 0 Then
  196.          LogData$(LogEnd) = Time$ + ":Keystroke was Intercepted :" + Chr$(13) + Chr$(10) + Chr$(9) + "Data=" + KeyInterceptText.Text + Chr$(13) + Chr$(10)
  197.          UpdateLogPointer
  198.          UpdateLog
  199.          LastInterceptedKeyLabel.Caption = KeyInterceptText.Text
  200.       End If
  201.    End If
  202. End Sub
  203.  
  204. Private Sub StartCommand_Click()
  205. On Error GoTo ErrHandler
  206.    FunctionComp = True
  207.    
  208.    OldMousePointer = MousePointer
  209.    MousePointer = 11 ' Hour Glass Mouse Pointer
  210.    
  211.    LastInterceptedKeyLabel.Caption = ""
  212.    
  213.    DisplayType$ = GetDisplayType$(SessionIdList.Text)
  214.    
  215.    If DisplayType$ = "NONE" Then
  216.       MousePointer = OldMousePointer
  217.       MsgBox MSG_INVALID_PSID + SessionIdList.Text, 48, MSG_SAMPLE_PROG
  218.       Exit Sub
  219.    End If
  220.    
  221.    Topic$ = GetTopicName()
  222.    If Len(Topic$) <= 0 Then
  223.      MousePointer = OldMousePointer
  224.      Exit Sub
  225.    End If
  226.       
  227.       Item$ = "KEYS"
  228.       rc = DoEvents()           'If you use VisualBasic V2.0, call
  229.                                 'DoEvents function each time before
  230.                                 'starting DDE conversation.
  231.       KeyInterceptText.LinkTimeout = -1
  232.       KeyInterceptText.LinkTopic = APPLICATION_NAME + "|" + Topic$
  233.       KeyInterceptText.LinkItem = Item$
  234.       KeyInterceptText.LinkMode = HOT
  235.        
  236.      MousePointer = OldMousePointer
  237.      If FunctionComp = True Then
  238.          ResultMessageLabel.Visible = True
  239.          EndStatus$ = MSG_OK
  240.          StartCommand.Enabled = False
  241.          StopCommand.Enabled = True
  242.          ExitCommand.Enabled = False
  243.       Else
  244.          ResultMessageLabel.Visible = False
  245.          MsgBox MSG_DDE_ERROR, 48, MSG_SAMPLE_PROG
  246.          EndStatus$ = MSG_NG
  247.       End If
  248.       TempLogData$ = Time$ + ":Start Keystroke Intercept : " + EndStatus$ + Chr$(13) + Chr$(10) + Chr$(9)
  249.       TempLogData$ = TempLogData$ + MSG_APPLICATION + APPLICATION_NAME + """" + Chr$(13) + Chr$(10) + Chr$(9)
  250.       TempLogData$ = TempLogData$ + MSG_TOPIC + """" + Topic$ + """" + Chr$(13) + Chr$(10) + Chr$(9)
  251.       TempLogData$ = TempLogData$ + MSG_ITEM + """" + Item$ + """" + Chr$(13) + Chr$(10)
  252.       LogData$(LogEnd) = TempLogData$
  253.       UpdateLogPointer
  254.       UpdateLog
  255.    Exit Sub
  256.  
  257. ErrHandler:
  258.    FunctionComp = False
  259.    Resume Next
  260. End Sub
  261.  
  262. Private Sub StopCommand_Click()
  263. On Error GoTo StopErrHandler
  264.    FunctionComp = True
  265.    
  266.    KeyInterceptText.LinkTimeout = -1
  267.    KeyInterceptText.LinkMode = NONE
  268.    StartCommand.Enabled = True
  269.    If FunctionComp = True Then
  270.       ResultMessageLabel.Visible = False
  271.       EndStatus$ = MSG_OK
  272.       StopCommand.Enabled = False
  273.       StartCommand.Enabled = True
  274.       ExitCommand.Enabled = True
  275.    Else
  276.       MsgBox MSG_DDE_ERROR, 48, MSG_SAMPLE_PROG
  277.       EndStatus$ = MSG_NG
  278.    End If
  279.    LogData$(LogEnd) = Time$ + ":Stop Keystroke Intercept : " + EndStatus$ + Chr$(13) + Chr$(10)
  280.    UpdateLogPointer
  281.    UpdateLog
  282.    Exit Sub
  283.  
  284. StopErrHandler:
  285.    FunctionComp = False
  286.    Resume Next
  287. End Sub
  288.  
  289. Private Sub TopicCheck_Click()
  290.  
  291.   If TopicCheck.Value = CHECKED Then
  292.      UserDefFrame.Enabled = False
  293.      UserDefStrText.Enabled = False
  294.   Else
  295.      UserDefFrame.Enabled = True
  296.      UserDefStrText.Enabled = True
  297.   End If
  298.   
  299.   
  300.   TopicLabel.Caption = GetTopicName()
  301. End Sub
  302.  
  303. Private Sub UpdateLog()
  304.     temp$ = " "
  305.     If LogTop > LogEnd Then
  306.        For i% = LogTop To MAXLOGNUM
  307.           temp$ = temp$ + LogData$(i%)
  308.        Next
  309.        For i% = 0 To LogEnd
  310.           temp$ = temp$ + LogData$(i%)
  311.        Next
  312.     ElseIf LogTop < LogEnd Then
  313.        For i% = LogTop To LogEnd
  314.           temp$ = temp$ + LogData(i%)
  315.        Next
  316.     Else
  317.        temp$ = LogData(i%)
  318.     End If
  319.     MainForm.FunctionLog.Text = temp$
  320.     Loged = False
  321. End Sub
  322.  
  323. Private Sub UpdateLogPointer()
  324.     LogEnd = LogEnd + 1
  325.     If LogEnd = MAXLOGNUM + 1 Then
  326.        LogEnd = 0
  327.     End If
  328.  
  329.     If LogTop = LogEnd Then
  330.        LogTop = LogTop + 1
  331.        If LogTop = MAXLOGNUM + 1 Then
  332.           LogTop = 0
  333.        End If
  334.     End If
  335. End Sub
  336.  
  337. Private Sub UserDefStrText_Change()
  338.   TopicLabel.Caption = GetTopicName()
  339. End Sub
  340.  
  341.  
  342.