04-22-2018, 10:07 PM (This post was last modified: 04-22-2018, 10:08 PM by win.)
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.
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
04-23-2018, 05:34 AM (This post was last modified: 04-23-2018, 05:38 AM by Gintaras.)
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.
[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. [/b]
[b]I think QM is a multi-functional assistant that can greatly improve the efficiency of learning and work. [/b]