CREATE Fonta AS QFONT
Name = "Arial"
Size = 12
Bold = 1
END CREATE
CREATE ToolKey_Form AS QFORM
CAPTION = "Key Test"
Width = 280
Height = 210
Top = 8
Left =(SCREEN.Width - 750) / 2
KeyPreview = True
OnKeyDown = ToolKey_Form_KeyDown
OnKeyUp = ToolKey_Form_KeyUp
OnKeyPress = ToolKey_Form_KeyPress
CREATE ToolKey_Lblin AS QLABEL
CAPTION = "IN:"
Width = 25
Height = 15
Top = 5
Left = 20
END CREATE
CREATE ToolKey_Char AS QEDIT
TabOrder = 1
Width = 32
Height = 25
Top = 20
Left = 20
MaxLength = 1
AutoSize = 0
OnKeyDown = Checkfield
OnKeyUp = Do_Keys
END CREATE
CREATE ToolKey_lblasc AS QLABEL
CAPTION = "ASCII:"
Width = 50
Height = 15
Left = ToolKey_Char.Left + ToolKey_Char.Width + 28
Top = ToolKey_Lblin.Top
END CREATE
CREATE ToolKey_Ascii AS QEDIT
ReadOnly = True
TabOrder = 5
Width = 32
Height = 28
Left = ToolKey_Char.Left + ToolKey_Char.Width + 28
Top = ToolKey_Char.Top
END CREATE
CREATE ToolKey_lbl2 AS QLABEL
Font.Size = 11
CAPTION = "OnKeyDown:"
Width = 90
Height = 15
Left = ToolKey_Char.Left
Top = ToolKey_Char.Top + ToolKey_Char.Height + 12
END CREATE
CREATE ToolKey_OnKeyDown_Txt AS QEDIT
ReadOnly = True
Font.Size = 11
Taborder = 2
Width = 120
Height = 25
Left = ToolKey_lbl2.Left + ToolKey_lbl2.Width + 18
Top = ToolKey_lbl2.Top
END CREATE
CREATE ToolKey_lbl3 AS QLABEL
Font.Size = 11
CAPTION = "OnKeyUp:"
Width = 90
Height = 15
Left = ToolKey_Char.Left
Top = ToolKey_lbl2.Top + ToolKey_lbl2.Height + 12
END CREATE
CREATE ToolKey_OnKeyUp_Txt AS QEDIT
ReadOnly = True
Font.Size = 11
Taborder = 3
Width = 120
Height = 25
Left = ToolKey_lbl3.Left + ToolKey_lbl3.Width + 18
Top = ToolKey_lbl3.Top
END CREATE
CREATE ToolKey_lbl4 AS QLABEL
Font.Size = 11
CAPTION = "OnKeyPress:"
Width = 90
Height = 15
Left = ToolKey_Char.Left
Top = ToolKey_lbl3.Top + ToolKey_lbl3.Height + 12
END CREATE
CREATE ToolKey_OnKeyPress_Txt AS QEDIT
ReadOnly = True
Font.Size = 11
Taborder = 4
Width = 120
Height = 25
Left = ToolKey_lbl4.Left + ToolKey_lbl4.Width + 18
Top = ToolKey_lbl4.Top
END CREATE
CREATE ToolKey_Clear AS QBUTTON
Top = ToolKey_lbl4.Top + ToolKey_lbl4.Height + 18
Left = ToolKey_Char.Left
CAPTION = "Clear Fields"
ShowHint = 1
Hint = "Some events don't trap\nsome keys - _
starting\nwith blank fields will\nshow _
which ones"
OnClick = ToolKey_Clear_Click
END CREATE
CREATE ToolKey_Btnmap AS QBUTTON
CAPTION = "Ascii >"
Width = 50
Taborder = 5
Left = ToolKey_OnKeyPress_Txt.Left + ToolKey_OnKeyPress_Txt.Width - ToolKey_Btnmap.Width
Top = ToolKey_Clear.Top
Height = 25
OnClick = ToolKey_ShowMap
END CREATE
CREATE ToolKey_BtnFont AS QBUTTON
CAPTION = "Font"
Taborder = 6
Left = ToolKey_Char.Left
Top = ToolKey_Btnmap.Top + ToolKey_Btnmap.Height + 20
Width = 65
Height = 25
OnClick = ToolKey_Getfont
Visible = 0
END CREATE
CREATE ToolKey_TexFont AS QEDIT
Text = Fonta.Name
Taborder = 7
Left = ToolKey_BtnFont.Left + ToolKey_BtnFont.Width + 8
Top = ToolKey_BtnFont.Top
Width = 150
Height = 28
ReadOnly = 1
Visible = 0
END CREATE
CREATE ToolKey_AscEdit AS QRICHEDIT
ReadOnly = True
Visible = False
Font = Fonta
Left = 8
Top =ToolKey_BtnFont.Top + ToolKey_BtnFont.Height + 18
Height = 500
ScrollBars = 3
Width = ToolKey_Form.ClientWidth - 18
END CREATE
END CREATE
ToolKey_AscEdit.AddStrings("Code" + Tab + "Dec." + Tab + "Hex")
FOR zzz = 13 TO 255
ToolKey_AscEdit.AddStrings( " " + CHR$(zzz) + Tab + STR$(zzz)+ Tab + "&h" + RIGHT$(HEX$(zzz),2))
NEXT zzz
SUB ToolKey_Form_Show
IF ToolKey_Form.Height = 210 THEN ToolKey_ShowMap
ToolKey_Form.Show
END SUB
SUB Do_Keys(Key AS WORD , Shift AS INTEGER)
DOEVENTS
IF LEN(ToolKey_Char.Text) > 0 THEN
ToolKey_Ascii.Text = STR$(ASC(ToolKey_Char.Text))
ELSE
ToolKey_Ascii.Text = ""
END IF
DOEVENTS
END SUB
SUB Checkfield
IF LEN(ToolKey_Char.Text) > 0 THEN
ToolKey_Char.Text = ""
END IF
DOEVENTS
END SUB
SUB ToolKey_ShowMap
STATIC Map
IF Map THEN
Map = 0
ToolKey_TexFont.Visible = 0
ToolKey_BtnFont.Visible = 0
ToolKey_AscEdit.Visible = 0
ToolKey_Form.Height = 210
ToolKey_Btnmap.CAPTION = "Ascii >"
ELSE
Map = 1
ToolKey_Form.ClientHeight = 740
ToolKey_TexFont.Visible = 1
ToolKey_BtnFont.Visible = 1
ToolKey_AscEdit.Visible = 1
ToolKey_Btnmap.CAPTION = "< Ascii"
END IF
SetFocus(ToolKey_Char.Handle)
DOEVENTS
END SUB
SUB ToolKey_Getfont
DEFINT Fs
FontDialog.Getfont(Fonta)
IF FontDialog.EXECUTE THEN
ToolKey_TexFont.Text = FontDialog.Name
FontDialog.Setfont(Fonta)
Fs = Fonta.Size
ToolKey_AscEdit.Font = Fonta:Fonta.Size = 12:ToolKey_Char.Font = Fonta
Fonta.Size = 48
Fonta.Size = Fs
END IF
SetFocus(ToolKey_Char.Handle)
DOEVENTS
END SUB
SUB ToolKey_Clear_Click
ToolKey_OnKeyDown_Txt.Text = ""
ToolKey_OnKeyUp_Txt.Text = ""
ToolKey_OnKeyPress_Txt.Text = ""
SetFocus(ToolKey_Char.Handle)
END SUB
SUB ToolKey_Form_KeyDown (Key AS WORD, Shift AS INTEGER)
ToolKey_OnKeyDown_Txt.Text = "Key: " + STR$(Key) + " Shift: " + STR$(Shift)
ToolKey_OnKeyUp_Txt.Text = ""
ToolKey_Char.Text = CHR$(Key)
SetFocus(ToolKey_Char.Handle)
END SUB
SUB ToolKey_Form_KeyUp (Key AS WORD, Shift AS INTEGER)
ToolKey_OnKeyDown_Txt.Text = ""
ToolKey_OnKeyUp_Txt.Text = "Key: " + STR$(Key) + " Shift: " + STR$(Shift)
ToolKey_OnKeyPress_Txt.Text = ""
SetFocus(ToolKey_Char.Handle)
END SUB
SUB ToolKey_Form_KeyPress (Key AS BYTE)
ToolKey_OnKeyUp_Txt.Text = ""
ToolKey_OnKeyPress_Txt.Text = "Key: " + STR$(Key)
SetFocus(ToolKey_Char.Handle)
END SUB
|