我使用VB做东西的,但最近碰见了问题,问了好多都解决不了。
所以本人来这里请教一下,能否通过调用API来解决。
问题使这样的。我在VB的一个窗体上方了一个播放Flash的控件。运行时要求Flash全屏显示。单击它时,进入主程序。但这个控件没有单击事件。能否通过调用API来解决。来捕获呢???
所以本人来这里请教一下,能否通过调用API来解决。
问题使这样的。我在VB的一个窗体上方了一个播放Flash的控件。运行时要求Flash全屏显示。单击它时,进入主程序。但这个控件没有单击事件。能否通过调用API来解决。来捕获呢???
得到点击的point判断后者是否在rect内
The PtInRect function determines whether the specified point lies within the specified rectangle. A point is within a rectangle if it lies on the left or top side or is within all four sides. A point on the right or bottom side is considered outside the rectangle. BOOL PtInRect(
CONST RECT *lprc, // pointer to structure with rectangle
POINT pt // structure with point
);这个函数就是用来判断某一点是否在某区域内的。你可以先截获鼠标消息,然后加入判短语句(至于VB具体怎么写这些语句,我的确是忘了语法)。
Private Declare Function SetWindowsHookEx Lib "user32" Alias _
"SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, _
ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Private Declare Function UnhookWindowsHookEx Lib "user32" _
(ByVal hHook As Long) As Long
Private Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, _
ByVal ncode As Long, ByVal wParam As Long, lParam As Any) As LongPublic hnexthookproc As Long
Const HC_ACTION = 0
Const WH_KEYBOARD = 2
Const WH_MOUSE = 7Public Sub UnHookKBD()
UnhookWindowsHookEx hnexthookproc
End SubPublic Function EnableKBDHook()
hnexthookproc = SetWindowsHookEx(7, AddressOf MyKBHFunc, App.hInstance, 0)
End FunctionPublic Function MyKBHFunc(ByVal iCode As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
If wParam = 513 Then ‘ 513 既是点击左键
UnHookKBD ‘卸载钩子函数
Unload Form1 ’ 执行到此处form1却无法卸载。form1上的flash仍在播放。
End If
End Function
以上代码在标准模块以下是form1的代码:
Private Sub Form_Load()
SF1.Height = Screen.Height
SF1.Width = Screen.Width
Form1.Height = Screen.Height
Form1.Width = Screen.Width
Form1.Top = 0
Form1.Left = 0
SF1.Movie = App.Path + "\1.swf"
Call EnableKBDHook
End SubPrivate Sub Form_Unload(Cancel As Integer)
Form2.Show 1
End Subform2为一空白框体