|
-
Dec 20th, 2002, 05:28 AM
#1
Thread Starter
New Member
OCX - trappin keypress Progress 4GL
Hello, I have a problem and hope that somebody of the VB experts around can help me out!
I am a Progress 4GL programmer but used VB to create a OCX-component to communicate
with the COM-port (based on the MSComm OCX).
The OCX-component works fine in Progress except one thing. The OCX-component waits defautl
0.5 seconds on a response of a printer on the COM-port.
I want to determine if a user pressed the Escape button during these 0.5 seconds. My thought was giving
back an extra-string if somebody pressed the escape key so I could analyze the string in Progress but I
don't manage to make this work. Here is my code, ...really hope somebody could help me out ! Thanks in advance.
Code im p_Seconds As Single
Dim p_Data As String
Dim sCheck As String
Public Function Check_Host_Status() As String
Check_Host_Status = Get_Answer("~HS")
End Function
Public Function Check_Host_Identification() As String
Check_Host_Identification = Get_Answer("~HI")
End Function
Public Function Check_Memory_Status() As String
Check_Memory_Status = Get_Answer("~HM")
End Function
Public Function Sleep(Seconds As Single, EventEnable As Boolean)
On Error GoTo ErrHndl
Dim OldTimer As Single
OldTimer = Timer
Do While (Timer - OldTimer) < Seconds
If EventEnable Then DoEvents
Loop
Exit Function
ErrHndl:
Err.Clear
End Function
Private Function Get_Answer(sCommando As String) As String
Dim sData As String
Dim nTemp As Integer
On Error GoTo ErrHndl
MSComm.PortOpen = True 'COM-poort openen
MSComm.Output = sCommando 'Control character sturen (Memory Status)
nTemp = Sleep(p_Seconds, True)
If MSComm.InBufferCount > 0 Then
sData = sData + MSComm.Input
End If
Get_Answer = sData + sCheck
MSComm.PortOpen = False 'COM-poort sluiten
Exit Function
ErrHndl:
Err.Clear
End Function
Public Function Output_String()
MSComm.PortOpen = True 'COM-poort openen
MSComm.Output = p_Data
MSComm.PortOpen = False 'COM-poort sluiten
End Function
Property Let Delay(sSeconds As Single)
p_Seconds = sSeconds
PropertyChanged "Delay"
End Property
Property Let Output(sData As String)
p_Data = sData
PropertyChanged "Output"
Output_String
End Property
Private Sub UserControl_Initialize()
p_Seconds = 0.5
End Sub
Private Sub UserControl_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyEscape Then sCheck = "Pressed"
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|