1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
| Public oForm1, oForm2
oForm1 = Createobject('FunctionSample1')
oForm2 = Createobject('FunctionSample2')
oForm1.Caption = "Bunda hic override yok"
oForm2.Caption = "F3 override - digerleri base"
oForm2.Left = 200
oForm2.Top = 200
oForm1.Show()
oForm2.Show()
Define Class FunctionSample1 As baseform
Height=400
Width=800
Add Object grdCustomer As Grid With ;
Left=5,Top=5,Height=390,Width=500,;
Anchor=1+2+4+128,RecordSource='crsCustomer'
Add Object lblCustomerID As Label With ;
left=510, Top= 5, Width=100,Alignment=1,Anchor=2+8,Caption='Customer ID'
Add Object lblCompany As Label With ;
left=510, Top=35, Width=100,Alignment=1,Anchor=2+8,Caption='Company'
Add Object lblContact As Label With ;
left=510, Top=65, Width=100,Alignment=1,Anchor=2+8,Caption='Contact'
Add Object txtCustomerID As TextBox With ;
left=615, Top= 5, Width=100,Anchor=2+8,ControlSource='crsCustomer.Cust_ID'
Add Object txtCompany As TextBox With ;
left=615, Top=35, Width=100,Anchor=2+8,ControlSource='crsCustomer.Company'
Add Object txtContact As TextBox With ;
left=615, Top=65, Width=100,Anchor=2+8,ControlSource='crsCustomer.Contact'
Procedure Load
Select * From (_samples+'Data\Customer') Into Cursor crsCustomer Readwrite
Use In 'Customer'
Endproc
Procedure grdCustomer.AfterRowColChange
Lparameters nColIndex
Thisform.Refresh()
Endproc
Enddefine
Define Class FunctionSample2 As baseform
Height=400
Width=800
Add Object grdCustomer As Grid With ;
Left=5,Top=5,Height=390,Width=790,;
Anchor=1+2+4+8,RecordSource='crsCustomer'
Procedure Load
Select * From (_samples+'Data\Customer') Into Cursor crsCustomer Readwrite
Use In 'Customer'
Endproc
* Overriding
Procedure OnFunctionKey(tnKeyNumber, tnShiftCtrl, tlHandled)
Local llShift,llCtrl
llShift = Bittest(m.tnShiftCtrl,0)
llCtrl = Bittest(m.tnShiftCtrl,1)
tlHandled = .T. && Key is handled here
Do Case
Case m.tnKeyNumber = 3 And m.tnShiftCtrl = 0 && F2
This.Caption = Textmerge('Function key F<<m.tnKeyNumber>> pressed. Handling override F3')
Otherwise
* digerlerini baseclass halletsin
DoDefault(m.tnKeyNumber, m.tnShiftCtrl, @m.tlHandled)
* ya da diger tuslarla isin yok
* tlHandled = .F.
Endcase
Endproc
Enddefine
Define Class baseform As Form
DataSession = 2
KeyPreview=.T.
Procedure KeyPress
Lparameters nKeyCode,nAltShiftCtrl
Local llFunctionPressed, llShift, llCtrl, llShiftCtrl
llShift = (m.nAltShiftCtrl = 1)
llCtrl = (m.nAltShiftCtrl = 2) Or (m.nAltShiftCtrl = 3)
llFunctionPressed = (Between(m.nKeyCode, -8, -1) Or ;
(Between(m.nKeyCode, 85, 92) And m.llShift) Or ;
(Between(m.nKeyCode, 95, 102) And m.llCtrl))
If m.llFunctionPressed
Local llHandled
This.HandleFunctionKey(m.nKeyCode,m.nAltShiftCtrl, @m.llHandled)
If m.llHandled && Tusun normaldeki islevini engelle
Nodefault
Endif
Endif
Endproc
Procedure HandleFunctionKey(tnKeyCode,tnAltShiftCtrl, tlHandled)
Local lnKeyNumber
Do Case
Case Between(m.tnKeyCode, -8, -1)
lnKeyNumber = Abs(m.tnKeyCode)+1
Case Between(m.tnKeyCode, 85, 92)
lnKeyNumber = m.tnKeyCode-85+2
Case Between(m.tnKeyCode, 95, 102)
lnKeyNumber = m.tnKeyCode-95+2
Endcase
This.OnFunctionKey(m.lnKeyNumber, m.tnAltShiftCtrl, @m.tlHandled)
Endproc
* Baz uygulama. Subclass formlarda override edilebilir
Procedure OnFunctionKey(tnKeyNumber, tnShiftCtrl, tlHandled)
Local llShift,llCtrl
llShift = Bittest(m.tnShiftCtrl,0)
llCtrl = Bittest(m.tnShiftCtrl,1)
tlHandled = .T. && Key is handled here
Do Case
Case m.tnKeyNumber = 3 And m.tnShiftCtrl = 0 && F3
This.Caption = Textmerge('Function key F<<m.tnKeyNumber>> pressed. Handling F3')
Case m.tnKeyNumber = 3 And !m.llCtrl And m.llShift && Shift+F3
This.Caption = Textmerge('Function key F<<m.tnKeyNumber>> pressed. Handling ShftF3')
Case m.tnKeyNumber = 3 And m.llCtrl And m.llShift && Shift+Ctrl+F3
This.Caption = Textmerge('Function key F<<m.tnKeyNumber>> pressed. Handling ShftCtrlF3')
Case m.tnKeyNumber = 4 And m.tnShiftCtrl = 0 && F4
This.Caption = Textmerge('Function key F<<m.tnKeyNumber>> pressed. Handling F4')
Case m.tnKeyNumber = 5 And m.tnShiftCtrl = 0 && F5
This.Caption = Textmerge('Function key F<<m.tnKeyNumber>> pressed. Handling F5')
Case m.tnKeyNumber = 5 And m.llCtrl And !m.llShift && Ctrl+F5
This.Caption = Textmerge('Function key F<<m.tnKeyNumber>> pressed. Handling CtrlF5')
Otherwise && digerlerini pas gectik
tlHandled = .F.
Endcase
Endproc
Enddefine |