我使用VB做东西的,但最近碰见了问题,问了好多都解决不了。
所以本人来这里请教一下,能否通过调用API来解决。
问题使这样的。我在VB的一个窗体上方了一个播放Flash的控件。运行时要求Flash全屏显示。单击它时,进入主程序。但这个控件没有单击事件。能否通过调用API来解决。来捕获呢???

解决方案 »

  1.   

    获得整个控件的rect
    得到点击的point判断后者是否在rect内
      

  2.   

    感谢楼上高手。能否说的详细点。我对API不甚了解。
      

  3.   

    我是用VC的,VB放下好多年了,忘了。不过API一样的用,你看:PtInRect
    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具体怎么写这些语句,我的确是忘了语法)。
      

  4.   

    感谢楼上,我的主要问题就是程序启动时,Flash在全屏播放。这时如何捕获鼠标单击事件。
      

  5.   

    如果Flash遮住了所有的窗口,也就是其他窗口无法响应鼠标或者键盘消息,那么……根据我多年前用VB作了本科毕业设计的经验,用Timer吧。做一个100ms的Timer,准实时监测用户的鼠标动作。嘿嘿,虽然看起来不够专业,但是一定管用。
      

  6.   

    如果你再问我怎么捕获用户鼠标信息……嗬嗬……我记得当时我用了钩子函数。靠,突然想起来了,用了钩子函数,还要个P的Timer啊?Sorry,sorry~~~~~呵呵……就用钩子函数吧。程序一起来,就把钩子按上,不管在那里动鼠标,你都可以检测到。哈哈……
      

  7.   

    我是学VB的,对API可一窍不通呀。
      

  8.   

    问高手一下。
    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为一空白框体