Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to disable pop-up menu on IE browser control or flash control
#1
Question 
I added a flash control, a IE browser control in a dialog box. When I press the right mouse button, the popup menu of the control will appear. I want to disable it, and then display my own definition  popup menu.

 I did not find any relevant information in the help. I hope someone can help me. Any suggestions and opinions are welcome. Thanks in advance.

Macro Macro1
Code:
Copy      Help
typelib ShockwaveFlashObjects {D27CDB6B-AE6D-11CF-96B8-444553540000} 1.0

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 544 266 "Dialog"
;3 ActiveX 0x54030000 0x0 8 8 256 216 "ShockwaveFlashObjects.ShockwaveFlash {D27CDB6E-AE6D-11CF-96B8-444553540000}"
;4 ActiveX 0x54030000 0x0 280 8 256 216 "SHDocVw.WebBrowser {8856F961-340A-11D0-A96B-00C04FD705A2}"
;1 Button 0x54030001 0x4 408 240 48 14 "OK"
;2 Button 0x54030000 0x4 476 240 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040700 "*" "" "" ""

str controls = "4"
str ax4SHD
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,SHDocVw.WebBrowser we4
,we4._getcontrol(id(4 hDlg))
,we4.Navigate("www.quickmacros.com")
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
#2
Finding some code in Google but I don't know how to use it

for c c++ 

Code:
Copy      Help
BOOL CWebBrowser2::PreTranslateMessage(MSG* pMsg)
{
   // TODO: Add your specialized code here and/or call the base class
   if(WM_RBUTTONDOWN == pMsg->message)
   {
       AfxMessageBox(_T("Right Menu!"));
       return TRUE;
   }
   return CWnd::PreTranslateMessage(pMsg);
}


for vb:

Dim WithEvents M_Dom As MSHTML.HTMLDocument 
Private Function M_Dom_oncontextmenu() As Boolean 
M_Dom_oncontextmenu = False 
End Function 
Private Sub Webbrowser1_DownloadComplete() 
Set M_Dom = Webbrowser1.Document  
me.PopupMenu mymenu 
End Sub
#3
A function like PreTranslateMessage can be created in two ways:
1. Use modeless dialog with message loop. It intercepts messages posted to the dialog and to its controls.
2. Use SetWindowsHookEx(WH_GETMESSAGE). It intercepts messages posted to any window or control of current thread.

Both intercept only posted messages, not sent messages. And it is rarely useful.

Usually need to intercept messages posted or sent to some 1 or several controls. Then subclass the controls.

In this case subclassing is not so easy as usually, because:
1. ActiveX controls usually have a child control. Need to find it (use child(...)).
2. Web browser's child control may be still not created when received WM_INITDIALOG. In this example I use timer as a workaround.

The #sub WndProc_Subclass can be created using template: menu -> File -> New -> Templates -> WndProc -> WndProc_Subclass.

Macro Macro3043
Code:
Copy      Help
typelib ShockwaveFlashObjects {D27CDB6B-AE6D-11CF-96B8-444553540000} 1.0

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 544 266 "Dialog"
;3 ActiveX 0x54030000 0x0 8 8 256 216 "ShockwaveFlashObjects.ShockwaveFlash {D27CDB6E-AE6D-11CF-96B8-444553540000}"
;4 ActiveX 0x54030000 0x0 280 8 256 216 "SHDocVw.WebBrowser {8856F961-340A-11D0-A96B-00C04FD705A2}"
;1 Button 0x54030001 0x4 408 240 48 14 "OK"
;2 Button 0x54030000 0x4 476 240 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040700 "*" "" "" ""

str controls = "4"
str ax4SHD
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,SetWindowSubclass(child("" "MacromediaFlashPlayerActiveX" id(3 hDlg)) &sub.WndProc_Subclass 1 0)
,SetTimer hDlg 1 100 0
,
,SHDocVw.WebBrowser we4
,we4._getcontrol(id(4 hDlg))
,we4.Navigate("www.quickmacros.com")
,
,case WM_TIMER
,sel wParam
,,case 1
,,int wies=child("" "Internet Explorer_Server" id(4 hDlg)); if(wies=0) ret
,,SetWindowSubclass(wies &sub.WndProc_Subclass 2 0)
,,KillTimer hDlg wParam
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1


#sub WndProc_Subclass
function# hwnd message wParam lParam uIdSubclass dwRefData

;OutWinMsg message wParam lParam ;;uncomment to see received messages

sel message
,case WM_RBUTTONDOWN
,out "Right Menu!"
,ret

int R=DefSubclassProc(hwnd message wParam lParam)

sel message
,case WM_NCDESTROY
,RemoveWindowSubclass(hwnd &sub.WndProc_Subclass uIdSubclass)
,
,;case ...

ret R
#4
@[b]Gintaras[/b]

[b]Thank you very much for your help. I don't understand the code above. However, I have collected it first. I will learn and think , afterwards. I believe, one day I will understand it. Smile
[/b]

[b]I think QM is a multi-functional assistant that can greatly improve the efficiency of learning and work. Exclamation [/b]
#5
Does it work on your computer? Should not show context menu.
#6
Can run, can pop up message box  Smile


Attached Files Image(s)
   
#7
The following code can pop up the right-click menu, but when the flash control is displayed in full screen, the flash control menu will still pop up. Huh

Macro dismenu 
Code:
Copy      Help
typelib ShockwaveFlashObjects {D27CDB6B-AE6D-11CF-96B8-444553540000} 1.0

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 544 266 "Dialog"
;3 ActiveX 0x54030000 0x0 8 8 256 216 "ShockwaveFlashObjects.ShockwaveFlash {D27CDB6E-AE6D-11CF-96B8-444553540000}"
;4 ActiveX 0x54030000 0x0 280 8 256 216 "SHDocVw.WebBrowser {8856F961-340A-11D0-A96B-00C04FD705A2}"
;1 Button 0x54030001 0x4 408 240 48 14 "OK"
;2 Button 0x54030000 0x4 476 240 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040700 "*" "" "" ""

str controls = "4"
str ax4SHD
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,ShockwaveFlashObjects.ShockwaveFlash sh3
,sh3._getcontrol(id(3 hDlg))
,sh3.LoadMovie(0 _s.expandpath("$desktop$\test.swf"))
,SetWindowSubclass(child("" "MacromediaFlashPlayerActiveX" id(3 hDlg)) &sub.WndProc_Subclass 1 0)
,SetTimer hDlg 1 100 0
,SHDocVw.WebBrowser we4
,we4._getcontrol(id(4 hDlg))
,we4.Navigate("http://static.flipbuilder.com/demo/sysco-seafood/index.html#p=1")
,
,case WM_TIMER
,sel wParam
,,case 1
,,int wies=child("" "Internet Explorer_Server" id(4 hDlg)); if(wies=0) ret
,,SetWindowSubclass(wies &sub.WndProc_Subclass 2 0)
,,KillTimer hDlg wParam
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1


#sub WndProc_Subclass
function# hwnd message wParam lParam uIdSubclass dwRefData

;OutWinMsg message wParam lParam ;;uncomment to see received messages

sel message
,case WM_RBUTTONDOWN
,str s=
,;1 Text
,;-
,;2 Text
,;>Submenu
,;,Text
,;,Text
,;,<
,MenuPopup x.AddItems(s)
,int i=x.Show
,ret

int R=DefSubclassProc(hwnd message wParam lParam)

sel message
,case WM_NCDESTROY
,RemoveWindowSubclass(hwnd &sub.WndProc_Subclass uIdSubclass)
,
,;case ...

ret R
#8
I don't know how to make it fullscreen. Probably then it is different window/control. Find that window, control, and subclass the control too.
#9
the mouse moves over the control, there will be a full screen prompt


Attached Files Image(s)
   


Forum Jump:


Users browsing this thread: 4 Guest(s)