Jump to content

Stop mouse right click on a WMPlayer.OCX object - video playing in a sub GUI - I can't do it


Recommended Posts

Posted (edited)

Hi - I've done my best but I can't solve it (don't have the skills). When I right click on the video I get a black box in the shape of the usual Windows popup. The code below shows the mouse right-click is successfully disabled for an input box and a combo box - but not for the video playing in the sub GUI. I have tried both methods to disable the right click on the video (that I got from this forum - thanks) but they do not work for the video....

(edit) Whoops - was calling the wrong MyProc function for the video right click disable on the video (should be MyProc2 - but then it crashes with an 'undeclared' var when I call the right function ...)

 

I've put the vid file here: https://www.mediafire.com/file/xxe6h414aa6m3i2/Relax.mp4/file

 

#include <WinAPI.au3>
#include <GUIConstants.au3>

Global $MainWin = GUICreate ( "Test GUI", 400, 400, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
Global $Input1 = GUICtrlCreateInput ("Input Box", 100, 100, 150, 20)
Global $ComboBox2 = GUICtrlCreateCombo("Combo Box", 100, 200, 150, 20)
GUICtrlSetData($ComboBox2, "More stuff|even more stuff")
Global $VidBut = GUICtrlCreateButton ("Play Video", 100, 300)

Global $msg = ""

HotKeySet("{ESC}", "_Quit")

; Right Click disable code - works OK for Input box
Global $hInput1 = GUICtrlGetHandle( $input1 ) ; Right click disable for Windows functions for my InputBox
Global $pInputProc = DllCallbackGetPtr( DllCallbackRegister( "InputProc", "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr" ) )
_WinAPI_SetWindowSubclass( $hInput1, $pInputProc, 9999, 0 ) ; SubclassId = 9999, $pData = 0

; Right Click disable code - works OK for combo box
Global $aPos = ControlGetPos ( $MainWin, "", $ComboBox2 ) ; Right click disable for Windows functions for my ComboBox
Global $hStub = DllCallbackRegister(MyProc, "LRESULT", "int;wparam;lparam")
Global $hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE, DllCallbackGetPtr($hStub), 0, _WinAPI_GetCurrentThreadId())

GUISetState () ; Display the GUI

While 1 ; Loop to get control events
    $msg = GUIGetMsg(0)
    If $msg = $VidBut Then
            GUISetState(@SW_HIDE, $MainWin) ; Hide the main GUI

            Global $SubGui = GUICreate("Sub GUI", 1156, 650, -1, -1, $WS_POPUP, $WS_EX_TOPMOST, $MainWin)
            GUISetState () ; Display the GUI

            ; Play the video
            Local $vid2 = ObjCreate("WMPlayer.OCX")
            Local $WMPLayer2 = GUICtrlCreateObj ( $vid2, 0, 0, 1156 , 650 )
            Local $file2 = (@ScriptDir & "\Relax.mp4")
            $vid2.URL = $file2
            $vid2.uiMode = "none"
            $vid2.controls.play

            ; Right Click disable code - not working for video
            Global $aPos2 = ControlGetPos ( $SubGui, "", $WMPLayer2 ) ; Right click disable for video
            Global $hStub2 = DllCallbackRegister(MyProc2, "LRESULT", "int;wparam;lparam")
            Global $hHook2 = _WinAPI_SetWindowsHookEx($WH_MOUSE, DllCallbackGetPtr($hStub2), 0, _WinAPI_GetCurrentThreadId())

    EndIf
WEnd


; InputProc callback function (disable right click for the Input box)
Func InputProc( $hWnd, $iMsg, $wParam, $lParam, $iSubclassId, $pData )
  Switch $iMsg
    Case $WM_CONTEXTMENU, $WM_PASTE, $EM_SHOWBALLOONTIP
      Return 0
  EndSwitch
  ; Call next function in subclass chain
  Return DllCall( "comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $iMsg, "wparam", $wParam, "lparam", $lParam )[0] ; _WinAPI_DefSubclassProc
EndFunc


; InputProc callback function (disable right click for the combo box)
Func MyProc($iMsg, $wParam, $lParam)
  If $iMsg = 0 Then
    If $wParam = $WM_RBUTTONDOWN Then
      Local $tPoint = DllStructCreate($tagPOINT, $lParam)
      _WinAPI_ScreenToClient($MainWin, $tPoint)
      If $tPoint.X >= $aPos[0] And $tPoint.X < $aPos[0] + $aPos[2] And $tPoint.Y >= $aPos[1] And $tPoint.Y < $aPos[1] + $aPos[3] Then
        Return 1
      EndIf
    EndIf
  EndIf
  Return _WinAPI_CallNextHookEx($hHook, $iMsg, $wParam, $lParam)
EndFunc


;---------------------------- testing for video in sub GUI right click disable - get a blacked-out popup box ---------------
; InputProc callback function (disable right click for video playing in sub GUI)
Func MyProc2($iMsg, $wParam, $lParam)
  If $iMsg = 0 Then
    If $wParam = $WM_RBUTTONDOWN Then
      Local $tPoint = DllStructCreate($tagPOINT, $lParam)
      _WinAPI_ScreenToClient($SubGui, $tPoint)
      If $tPoint.X >= $aPos2[0] And $tPoint.X < $aPos2[0] + $aPos2[2] And $tPoint.Y >= $aPos2[1] And $tPoint.Y < $aPos2[1] + $aPos2[3] Then
        Return 1
      EndIf
    EndIf
  EndIf
  Return _WinAPI_CallNextHookEx($hHook2, $iMsg, $wParam, $lParam)
EndFunc
;----------------------------------- testing stuff ----------------


Func _Quit()
    Exit
EndFunc

 

Edited by Toyley2
errors
Posted (edited)

Well you need to use another type of hook, since the OCX is not fully part of the GUI.  I suggest you remove the subclassing method to replace it with the WM_MOUSE hook and add this new hook.  I changed the grouping of your code to make it more modular :

#include <Array.au3>
#include <WinAPI.au3>
#include <GUIConstants.au3>

Opt("MustDeclareVars", True)

Global $MainWin, $hHook, $SubGui, $hHook2

Main()

Func Main()
  $MainWin = GUICreate("Test GUI", 400, 400, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
  Local $Input1 = GUICtrlCreateInput("Input Box", 100, 100, 150, 20)
  Local $ComboBox2 = GUICtrlCreateCombo("Combo Box", 100, 200, 150, 20)
  GUICtrlSetData($ComboBox2, "More stuff|even more stuff")
  Local $VidBut = GUICtrlCreateButton("Play Video", 100, 300)

  Local $msg

  Global $aPos[] = [ControlGetPos($MainWin, "", $ComboBox2), ControlGetPos($MainWin, "", $Input1)]
  Local $hStub = DllCallbackRegister(MyProc, "LRESULT", "int;wparam;lparam")
  $hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE, DllCallbackGetPtr($hStub), 0, _WinAPI_GetCurrentThreadId())

  GUISetState() ; Display the GUI

  While True
    Switch GUIGetMsg()
      Case $VidBut
        GUISetState(@SW_HIDE, $MainWin)
        SubGUI()
        GUISetState(@SW_SHOW, $MainWin)
      Case $GUI_EVENT_CLOSE
        ExitLoop
    EndSwitch
  WEnd
  GUIDelete($MainWin)
  _WinAPI_UnhookWindowsHookEx($hHook)
  DllCallbackFree($hStub)
EndFunc   ;==>Main

Func SubGUI()
  $SubGui = GUICreate("Sub GUI", 1156, 650, -1, -1, $WS_POPUP, $WS_EX_TOPMOST, $MainWin)
  GUISetState()        ; Display the GUI

  ; Play the video
  Local $vid2 = ObjCreate("WMPlayer.OCX")
  Local $WMPLayer2 = GUICtrlCreateObj($vid2, 0, 0, 1156, 650)
  Local $file2 = (@ScriptDir & "\Relax.mp4")
  $vid2.URL = $file2
  $vid2.uiMode = "none"
  $vid2.controls.play

  Local $hStub2 = DllCallbackRegister(MyProc2, "LRESULT", "int;wparam;lparam")
  $hHook2 = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($hStub2), _WinAPI_GetModuleHandle(0))

  Sleep(2000)

  While $vid2.playState = 3
    If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
  WEnd

  GUIDelete($SubGui)
  _WinAPI_UnhookWindowsHookEx($hStub2)
  DllCallbackFree($hHook2)
EndFunc   ;==>SubGUI

Func MyProc($iMsg, $wParam, $lParam)
  If $iMsg = 0 Then
    If $wParam = $WM_RBUTTONDOWN Then
      Local $tPoint = DllStructCreate($tagPOINT, $lParam)
      _WinAPI_ScreenToClient($MainWin, $tPoint)
      For $i = 0 To UBound($aPos) - 1
        If $tPoint.X >= ($aPos[$i])[0] And $tPoint.X < ($aPos[$i])[0] + ($aPos[$i])[2] And $tPoint.Y >= ($aPos[$i])[1] And $tPoint.Y < ($aPos[$i])[1] + ($aPos[$i])[3] Then
          Return 1
        EndIf
      Next
    EndIf
  EndIf
  Return _WinAPI_CallNextHookEx($hHook, $iMsg, $wParam, $lParam)
EndFunc   ;==>MyProc

Func MyProc2($iMsg, $wParam, $lParam)
  If $iMsg = 0 Then
    If ($wParam = $WM_RBUTTONDOWN Or $wParam = $WM_RBUTTONUP) And WinGetHandle("[ACTIVE]") = $SubGui Then
      Return 1
    EndIf
  EndIf
  Return _WinAPI_CallNextHookEx($hHook2, $iMsg, $wParam, $lParam)
EndFunc   ;==>MyProc2

 

Edited by Nine
Posted

Hi - thanks Nine - I appreciate the help

I thought I had mastered it - I had all the GUI controls (out of the 23 available) that were doing Windows stuff on mouse right-clicks doing nothing after intercepting the mouse right clicks - but things I want to do with the right mouse click are difficult because I'm getting mouse co-ordinates of trillions of pixels (20 digit numbers) and mouse click echoes and spurious function calls .... - I'll try and work it out 

Posted (edited)

I was doing a general help thing for mouse right-click intercepts but the strange mouse co-ordinates and right-click echoes (on the embedded object in the GUI) have me beaten - you might be able to fix it - I have done all the donkey-work but I don't have the skills for the difficult stuff

#include <Array.au3>
#include <WinAPI.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <Misc.au3> ; For trapping right clicks anywhere

AutoItSetOption("MouseCoordMode", 0) ; I want the mouse coordinates relative to the GUI window - not the entire screen

Opt("MustDeclareVars", True)

Global $MainWin, $hHook, $SubGui, $hHook2, $ContextHelpF, $MousePos

Main()

Func Main()
    $MainWin = GUICreate("GUI Controls : Windows Mouse Right-Click Intercept Round-up (so you can do your own custom context-help on GUI controls using mouse right-click)", 1000, 600, -1, -1)

    Local $Avi = GuiCtrlCreateAvi(@ScriptDir & "\sampleAVI.avi",20, 20, 10, 32, 32, $ACS_AUTOPLAY)

    Local $Button = GUICtrlCreateButton("button", 20, 50)

    Local $idCheckbox = GUICtrlCreateCheckbox("Checkbox", 20, 80, 72, 25)

    Local $ComboBox2 = GUICtrlCreateCombo("Combo Box", 20, 110, 150, 20)
        GUICtrlSetData($ComboBox2, "More stuff|even more stuff")

        ; GUICtrlCreateContextMenu - does not apply

    Local $DateB = GUICtrlCreateDate ( "date", 20, 140 )

        ; GUICtrlCreateDummy - does not apply

    Local $Edit = GUICtrlCreateEdit("First line" & @CRLF, 20, 165, 121, 30, $ES_AUTOVSCROLL + $WS_VSCROLL)

    Local $graphic = GUICtrlCreateGraphic(20, 205, 100, 100)
    GUICtrlSetBkColor(-1, 0xffffff)
    GUICtrlSetColor(-1, 0)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000, 0xff0000)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 50, 50, 40, 30, 270)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00ff00, 0xffffff)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 58, 50, 40, -60, 90)

    GUICtrlCreateGroup("Group 1", 20, 315, 100, 30)
    GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group

    GUICtrlCreateIcon("shell32.dll", 10, 20, 350)

    Local $Input1 = GUICtrlCreateInput("Input Box", 20, 390, 150, 20)

    GUICtrlCreateLabel("[Control Label]", 20, 420)

    Local $List = GUICtrlCreateList("A list", 20, 450, 121, 40)
    GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling
    GUICtrlSetData(-1, "hello")
    GUICtrlSetData(-1, "goodbye")

    Local $Listview = GUICtrlCreateListView("col1|col2|col3", 20, 490, 150, 30)

        ; GUICtrlCreateListViewItem - does not apply

    Local $Menu = GuiCtrlCreateMenu ("  " & "= GUICtrlCreateMenu  [This is a menu - no mouse right-click intercept needed because no Windows antics on mouse right click over this GUI control]")
    Local $idFileitem = GUICtrlCreateMenuItem("Pretend Open", $Menu)
    Local $idInfoitem = GUICtrlCreateMenuItem("Pretend Info", $Menu)
    Local $idExititem = GUICtrlCreateMenuItem("Pretend Exit", $Menu)

    Local $iDate = GUICtrlCreateMonthCal("1953/03/25", 20, 530)

    Local $oIE = ObjCreate("Shell.Explorer.2")
    Local $Object1 = GUICtrlCreateObj($oIE, 250+150, 20, 200, 175)
    $oIE.navigate("http://google.com")
    Local $hStub2 = DllCallbackRegister(MyProc3, "LRESULT", "int;wparam;lparam")
    $hHook2 = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($hStub2), _WinAPI_GetModuleHandle(0))
    ; >>>>>>> this blocks mouse right click on entire GUI - not what I want

    Local $VidBut = GUICtrlCreateButton("Play Video (object) in a sub-GUI", 250+150, 200)

    GUICtrlCreatePic(@ScriptDir & "\Invert\Jeer2.bmp", 250+150, 230, 31, 32)

    Local $Progressbar1 = GUICtrlCreateProgress(250+150, 265, 200, 20)
    GUICtrlSetData($Progressbar1, 50)

    Local $Radio1 = GUICtrlCreateRadio("Radio 1", 250+150, 290, 60, 20)
    Local $Radio2 = GUICtrlCreateRadio("Radio 2", 320+150, 290, 60, 20)
    GUICtrlSetState($Radio2, $GUI_CHECKED)

    Local $idSlider1 = GUICtrlCreateSlider(250+150, 320, 200, 20)
    GUICtrlSetLimit(-1, 200, 0) ; change min/max value
    GUICtrlSetData($idSlider1, 45) ; set cursor

    Local $Tab = GUICtrlCreateTab(510-260+150, 10+340, 200, 100)

    GUICtrlCreateTabItem("tab0")
    GUICtrlCreateLabel("Stuff", 530-260+150, 80+340, 50, 20)
    GUICtrlCreateButton("OK", 520-260+150, 50+340, 50, 20)
    GUICtrlCreateInput("default", 580-260+150, 50+340, 70, 20)

    GUICtrlCreateTabItem("tab1")
    GUICtrlCreateLabel("More Stuff", 530-260+150, 80+340, 50, 20)
    GUICtrlCreateCombo("", 520-260+150, 50+340, 60, 120)
    GUICtrlSetData(-1, "Trids|Cyber|Larry|Jon|Tylo|Cheese", "Jon") ; default Jon
    GUICtrlCreateButton("OK", 580-260+150, 50+340, 50, 20)
    GUICtrlCreateTabItem(""); end tabitem definition

        ; GUICtrlCreateTabItem - does not apply

    Local $idTreeview = GUICtrlCreateTreeView(250+150, 460, 100, 50, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
    Local $idGeneralitem = GUICtrlCreateTreeViewItem("General", $idTreeview)
    GUICtrlSetColor(-1, 0x0000C0)
    Local $idDisplayitem = GUICtrlCreateTreeViewItem("Display", $idTreeview)
    GUICtrlSetColor(-1, 0x0000C0)
    Local $idAboutitem = GUICtrlCreateTreeViewItem("About", $idGeneralitem)
    Local $idCompitem = GUICtrlCreateTreeViewItem("Computer", $idGeneralitem)
    GUICtrlCreateTreeViewItem("User", $idGeneralitem)
    GUICtrlCreateTreeViewItem("Resolution", $idDisplayitem)

    Local $idInput = GUICtrlCreateInput("2", 250+150, 525, 50, 20)
    GUICtrlCreateUpdown($idInput)

    ;------------------- Code labels for GUI controls
    GUICtrlCreateLabel(" = GUICtrlCreateAvi", 75-15, 20)
    GUICtrlCreatePic(@ScriptDir & "\cross.jpg", 175-15 , 18, 20, 20)

    GUICtrlCreateLabel(" = GUICtrlCreateButton", 70-5, 55)
    GUICtrlCreatePic(@ScriptDir & "\cross.jpg", 183-5, 53, 20, 20)

    GUICtrlCreateLabel(" = GUICtrlCreateCheckbox", 70+20, 85)
    GUICtrlCreatePic(@ScriptDir & "\cross.jpg", 198+20, 83, 20, 20)

    GUICtrlCreateLabel(" = GUICtrlCreateCombo", 175, 110)
    GUICtrlCreatePic(@ScriptDir & "\tick.jpg", 290, 103, 20, 20)

    GUICtrlCreateLabel(" = GUICtrlCreateDate", 175, 140)
    GUICtrlCreatePic(@ScriptDir & "\cross.jpg", 283, 139, 20, 20)

    GUICtrlCreateLabel(" = GUICtrlCreateEdit", 150, 170)
    GUICtrlCreatePic(@ScriptDir & "\tick.jpg", 250, 164, 20, 20)

    GUICtrlCreateLabel(" = GUICtrlCreateGraphic", 128, 241)
    GUICtrlCreatePic(@ScriptDir & "\cross.jpg", 247, 240, 20, 20)

    GUICtrlCreateLabel(" = GUICtrlCreateGroup", 125, 324)
    GUICtrlCreatePic(@ScriptDir & "\cross.jpg", 236, 323, 20, 20)

    GUICtrlCreateLabel(" = GUICtrlCreateIcon", 60, 361)
    GUICtrlCreatePic(@ScriptDir & "\cross.jpg", 163, 360, 20, 20)

    GUICtrlCreateLabel(" = GUICtrlCreateInput", 175, 391)
    GUICtrlCreatePic(@ScriptDir & "\tick.jpg", 285, 387, 20, 20)

    GUICtrlCreateLabel(" = GUICtrlCreateLabel", 92, 420)
    GUICtrlCreatePic(@ScriptDir & "\cross.jpg", 202, 419, 20, 20)

    GUICtrlCreateLabel(" = GUICtrlCreateList", 148, 458)
    GUICtrlCreatePic(@ScriptDir & "\cross.jpg", 246, 456, 20, 20)

    GUICtrlCreateLabel(" = GUICtrlCreateListView", 175, 496)
    GUICtrlCreatePic(@ScriptDir & "\cross.jpg", 295, 495, 20, 20)

    GUICtrlCreateLabel(" = GUICtrlCreateMonthCal", 179, 538)
    GUICtrlCreatePic(@ScriptDir & "\tick.jpg", 308, 531, 20, 20)

    GUICtrlCreateLabel(" = GUICtrlCreateObj", 605, 100)
    GUICtrlCreatePic(@ScriptDir & "\tick.jpg", 705, 95, 20, 20)

    GUICtrlCreateLabel(" = GUICtrlCreateObj in a sub-GUI", 560, 198)
    GUICtrlCreateLabel("    ( a video window for example )", 560, 213)
    GUICtrlCreatePic(@ScriptDir & "\tick.jpg", 730, 200, 20, 20)

    GUICtrlCreateLabel(" = GUICtrlCreatePic", 435, 238)
    GUICtrlCreatePic(@ScriptDir & "\cross.jpg", 530, 238, 20, 20)

    GUICtrlCreateLabel(" = GUICtrlCreateProgress", 605, 268)
    GUICtrlCreatePic(@ScriptDir & "\cross.jpg", 729, 267, 20, 20)

    GUICtrlCreateLabel(" = GUICtrlCreateRadio", 529, 293)
    GUICtrlCreatePic(@ScriptDir & "\cross.jpg", 640, 292, 20, 20)

    GUICtrlCreateLabel(" = GUICtrlCreateSlider", 605, 323)
    GUICtrlCreatePic(@ScriptDir & "\cross.jpg", 715, 319, 20, 20)

    GUICtrlCreateLabel(" = GUICtrlCreateTab", 605, 400)
    GUICtrlCreatePic(@ScriptDir & "\tick.jpg", 708, 397, 20, 20)

    GUICtrlCreateLabel(" = GUICtrlCreateTreeView", 510, 480)
    GUICtrlCreatePic(@ScriptDir & "\tick.jpg", 638, 477, 20, 20)

    GUICtrlCreateLabel(" = GUICtrlCreateUpdown", 457, 526)
    GUICtrlCreatePic(@ScriptDir & "\tick.jpg", 585, 523, 20, 20)

    GUICtrlCreatePic(@ScriptDir & "\forumtxt.jpg", 760, 15, 236, 361)
    GUICtrlCreatePic(@ScriptDir & "\forumtxt2.jpg", 284, 195, 114, 184)

    Local $ContextHelpBut = GUICtrlCreateButton("Custom Context Help on/off", 810, 430)
    GUICtrlSetBkColor($ContextHelpBut, 0xFF6347) ; Red = off
    $ContextHelpF = 0 ; Initialise the custom context flag

    Local $msg

    Global $aPos[] = [ControlGetPos($MainWin, "", $ComboBox2), _
    ControlGetPos($MainWin, "", $Input1), _
    ControlGetPos($MainWin, "", $idInput), _
    ControlGetPos($MainWin, "", $Tab), _
    ControlGetPos($MainWin, "", $idTreeview), _
    ControlGetPos($MainWin, "", $Edit)]

    ; Scrollbars on some controls have their own mouse right-click pop-ups (even when the mouse right-clicks
    ;on the control are sucessfully intercepted) - I think the 'WM_MOUSE hook' method should be a way round this

    Global $hInput1 = GUICtrlGetHandle( $iDate ) ; Right click disable for Windows functions for 'month calendar control' (Lars method)
    Global $pInputProc = DllCallbackGetPtr( DllCallbackRegister( "InputProc", "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr" ) )
    _WinAPI_SetWindowSubclass( $hInput1, $pInputProc, 9999, 0 ) ; SubclassId = 9999, $pData = 0

    Local $hStub = DllCallbackRegister(MyProc, "LRESULT", "int;wparam;lparam")
    $hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE, DllCallbackGetPtr($hStub), 0, _WinAPI_GetCurrentThreadId())

    GUISetState()

    While True
        If _IsPressed("02") Then ; mouse right click anywhere test (case does not work)
            ;MsgBox($MB_SYSTEMMODAL, "", "right click >>~?????????.")
            ;CustContextHelp()
            $MousePos = MouseGetPos()
            MsgBox($MB_SYSTEMMODAL, "", "just R mouse press x y " & $MousePos[0] & " " & $MousePos[1], 1)
        Endif
        Switch GUIGetMsg()
            Case $ContextHelpBut
                If $ContextHelpF = 0 Then
                    $ContextHelpF = 1
                    GUICtrlSetBkColor($ContextHelpBut, 0x9ACD32) ; Green = on
                Else
                    $ContextHelpF = 0
                    GUICtrlSetBkColor($ContextHelpBut, 0xFF6347) ; Red = off
                EndIf
        Case $VidBut
            GUISetState(@SW_HIDE, $MainWin)
            SubGUI()
            GUISetState(@SW_SHOW, $MainWin)
        Case $GUI_EVENT_CLOSE
            ExitLoop
        EndSwitch
    WEnd
    GUIDelete($MainWin)
    _WinAPI_UnhookWindowsHookEx($hHook)
    DllCallbackFree($hStub)
EndFunc   ;==>Main

Func SubGUI()
  $SubGui = GUICreate("Sub GUI", 1156, 650, -1, -1, $WS_POPUP, $WS_EX_TOPMOST, $MainWin)
  GUISetState()
  Local $vid2 = ObjCreate("WMPlayer.OCX")  ; Play the video
  Local $WMPLayer2 = GUICtrlCreateObj($vid2, 0, 0, 1156, 650)
  Local $file2 = (@ScriptDir & "\Relax.mp4")
  $vid2.URL = $file2
  $vid2.uiMode = "none"
  $vid2.controls.play

  Local $hStub2 = DllCallbackRegister(MyProc2, "LRESULT", "int;wparam;lparam")
  $hHook2 = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($hStub2), _WinAPI_GetModuleHandle(0))

  Sleep(2000)

  While $vid2.playState = 3
    If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
  WEnd

  GUIDelete($SubGui)
  _WinAPI_UnhookWindowsHookEx($hStub2)
  DllCallbackFree($hHook2)
EndFunc   ;==>SubGUI

Func MyProc($iMsg, $wParam, $lParam)
  If $iMsg = 0 Then
    If $wParam = $WM_RBUTTONDOWN Then
      Local $tPoint = DllStructCreate($tagPOINT, $lParam)
      _WinAPI_ScreenToClient($MainWin, $tPoint)
      For $i = 0 To UBound($aPos) - 1
        If $tPoint.X >= ($aPos[$i])[0] And $tPoint.X < ($aPos[$i])[0] + ($aPos[$i])[2] And $tPoint.Y >= ($aPos[$i])[1] And $tPoint.Y < ($aPos[$i])[1] + ($aPos[$i])[3] Then
          Return 1
        EndIf
      Next
    EndIf
  EndIf
  Return _WinAPI_CallNextHookEx($hHook, $iMsg, $wParam, $lParam)
EndFunc   ;==>MyProc

Func MyProc2($iMsg, $wParam, $lParam)
  If $iMsg = 0 Then
    If ($wParam = $WM_RBUTTONDOWN Or $wParam = $WM_RBUTTONUP) And WinGetHandle("[ACTIVE]") = $SubGui Then
      Return 1
    EndIf
  EndIf
  Return _WinAPI_CallNextHookEx($hHook2, $iMsg, $wParam, $lParam)
EndFunc   ;==>MyProc2

Func MyProc3($iMsg, $wParam, $lParam) ; For the Object embedded in main GUI
  $MousePos = MouseGetPos()
  If $MousePos[0] > 400 And $MousePos[0] < 600 And $MousePos[1] > 20 And $MousePos[1] < 195 Then
      If $iMsg = 0 Then
            If ($wParam = $WM_RBUTTONDOWN Or $wParam = $WM_RBUTTONUP) And WinGetHandle("[ACTIVE]") = $MainWin _
            And $MousePos[0] > 400 And $MousePos[0] < 600 And $MousePos[1] > 20 And $MousePos[1] < 195 Then ; Isolate the object area again?
            MsgBox($MB_SYSTEMMODAL, "", "embedded object")
            sleep(5000)
                Return 1
            EndIf
      EndIf
  EndIf
  Return _WinAPI_CallNextHookEx($hHook2, $iMsg, $wParam, $lParam)
EndFunc   ;==>MyProc3

Func InputProc( $hWnd, $iMsg, $wParam, $lParam, $iSubclassId, $pData ) ; Disable right click for the monthly calender GUI control
  Switch $iMsg
    Case $WM_CONTEXTMENU, $WM_PASTE, $EM_SHOWBALLOONTIP
      Return 0
  EndSwitch
  ; Call next function in subclass chain
  Return DllCall( "comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $iMsg, "wparam", $wParam, "lparam", $lParam )[0] ; _WinAPI_DefSubclassProc
EndFunc ;==>InputProc






Func CustContextHelp()
    ;If $ContextHelpF = 0 Then Return ; Custom context help turned off
    $MousePos = MouseGetPos()
    ;MsgBox($MB_SYSTEMMODAL, "", "Combo box x y " & $MousePos[0] & " " & $MousePos[1], 2)
    ;Local $ComboBox2 = GUICtrlCreateCombo("Combo Box", 20, 110, 150, 20)
    If $MousePos[0] > 20 And $MousePos[0] < 170 And $MousePos[1] > 110 And $MousePos[1] < 130 Then
        MsgBox($MB_SYSTEMMODAL, "", "Combo box")
    EndIf

    If $MousePos[0] > 400 And $MousePos[0] < 600 And $MousePos[1] > 20 And $MousePos[1] < 195 Then
        MsgBox($MB_SYSTEMMODAL, "", "embedded object")
    EndIf

    If $MousePos[0] > 400 And $MousePos[0] < 600 And $MousePos[1] > 320 And $MousePos[1] < 340 Then
        MsgBox($MB_SYSTEMMODAL, "", "slider")
    EndIf
    ; If the mouse right-click is not on anything of interest - do nothing
EndFunc

 

Edited by Toyley2

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...