-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfrmSelectButtonPos.frm
216 lines (198 loc) · 6.53 KB
/
frmSelectButtonPos.frm
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
VERSION 5.00
Begin VB.Form frmSelectButtonPos
BorderStyle = 1 'Fixed Single
Caption = "选择位置"
ClientHeight = 1815
ClientLeft = 45
ClientTop = 375
ClientWidth = 1800
KeyPreview = -1 'True
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1815
ScaleWidth = 1800
StartUpPosition = 1 'CenterOwner
Begin VB.Timer tmrGetKeyState
Interval = 10
Left = 1080
Top = 1080
End
Begin VB.CommandButton cmdPos
Appearance = 0 'Flat
Caption = "↑"
Height = 615
Index = 1
Left = 600
TabIndex = 1
ToolTipText = "上方"
Top = 0
Width = 615
End
Begin VB.CommandButton cmdPos
Appearance = 0 'Flat
Caption = "→"
Height = 615
Index = 5
Left = 1200
TabIndex = 5
ToolTipText = "右边"
Top = 600
Width = 615
End
Begin VB.CommandButton cmdPos
Appearance = 0 'Flat
Caption = "↓"
Height = 615
Index = 7
Left = 600
TabIndex = 7
ToolTipText = "下方"
Top = 1200
Width = 615
End
Begin VB.CommandButton cmdPos
Appearance = 0 'Flat
Caption = "↘"
Height = 615
Index = 8
Left = 1200
TabIndex = 8
ToolTipText = "右下"
Top = 1200
Width = 615
End
Begin VB.CommandButton cmdPos
Appearance = 0 'Flat
Caption = "↗"
Height = 615
Index = 2
Left = 1200
TabIndex = 2
ToolTipText = "右上"
Top = 0
Width = 615
End
Begin VB.CommandButton cmdPos
Appearance = 0 'Flat
Caption = "←"
Height = 615
Index = 3
Left = 0
TabIndex = 3
ToolTipText = "左边"
Top = 600
Width = 615
End
Begin VB.CommandButton cmdPos
Appearance = 0 'Flat
Caption = "↙"
Height = 615
Index = 6
Left = 0
TabIndex = 6
ToolTipText = "左下"
Top = 1200
Width = 615
End
Begin VB.CommandButton cmdPos
Appearance = 0 'Flat
Caption = "↖"
Height = 615
Index = 0
Left = 0
TabIndex = 0
ToolTipText = "左上"
Top = 0
Width = 615
End
Begin VB.CommandButton cmdPos
Appearance = 0 'Flat
Caption = "●"
Height = 615
Index = 4
Left = 600
TabIndex = 4
ToolTipText = "中间"
Top = 600
Width = 615
End
End
Attribute VB_Name = "frmSelectButtonPos"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub cmdPos_Click(Index As Integer)
Dim RetValue As Long '需要增加的样式
Const RemoveValue = BS_LEFT Or BS_RIGHT Or BS_BOTTOM Or BS_TOP Or BS_CENTER
Select Case Index
Case 0 '↖
RetValue = BS_LEFT Or BS_TOP
Case 1 '↑
RetValue = BS_TOP
Case 2 '↗
RetValue = BS_RIGHT Or BS_TOP
Case 3 '←
RetValue = BS_LEFT
Case 4 '●
RetValue = BS_CENTER
Case 5 '→
RetValue = BS_RIGHT
Case 6 '↙
RetValue = BS_LEFT Or BS_BOTTOM
Case 7 '↓
RetValue = BS_BOTTOM
Case 8 '↘
RetValue = BS_RIGHT Or BS_BOTTOM
End Select
'设置窗体样式
frmProperties.ApplyProp False, , , RetValue, RemoveValue
frmProperties.labPropValue(frmProperties.NowIndex).Caption = Me.cmdPos(Index).Caption
MainPropList(frmProperties.CurrentTarget, frmProperties.NowIndex, 0) = Me.cmdPos(Index).Caption
'刷新窗体
frmTarget.Move -frmTarget.Width, -frmTarget.Height, frmTarget.Width, frmTarget.Height
frmTarget.Move 0, 0, frmTarget.Width, frmTarget.Height
'关闭窗体
Unload Me
End Sub
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
'响应Esc键
If KeyCode = vbKeyEscape Then
Unload Me
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
'让主窗体可用
frmMain.Enabled = True
frmMain.SetFocus
End Sub
Private Sub tmrGetKeyState_Timer()
If GetForegroundWindow = Me.hWnd Then '需要本窗体获取焦点
On Error Resume Next
Dim NewIndex As Integer '目标控件的索引
Dim IsKeyDown As Boolean '是否按下按键
NewIndex = 4 '初始化为中间的按钮
IsKeyDown = False '初始化为未按下按键
If GetAsyncKeyState(vbKeyLeft) <> 0 Then '←
NewIndex = NewIndex - 1
IsKeyDown = True
End If
If GetAsyncKeyState(vbKeyRight) <> 0 Then '→
NewIndex = NewIndex + 1
IsKeyDown = True
End If
If GetAsyncKeyState(vbKeyUp) <> 0 Then '↑
NewIndex = NewIndex - 3
IsKeyDown = True
End If
If GetAsyncKeyState(vbKeyDown) <> 0 Then '↓
NewIndex = NewIndex + 3
IsKeyDown = True
End If
If IsKeyDown Then '需要按下按键再使指定控件获取焦点
Me.cmdPos(NewIndex).SetFocus
End If
End If
End Sub