Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > .NET Languages
You last visited: Today at 14:05

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[help] WebBrowser ContextMenu

Discussion on [help] WebBrowser ContextMenu within the .NET Languages forum part of the Coders Den category.

Reply
 
Old   #1
 
PraDevil[ELITE]'s Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 1,486
Received Thanks: 919
[help] WebBrowser ContextMenu

i create a program which open the folder directory of my own computer and url that load it to my webbrowser control, and i'll disable the context menu from appear on the webbrowser while right clicking, yes it does it..but its only done when its was a website url and not a my computer directory..how i can disable completely this right click features on my webbrowser even on my whole project? in detail i made a program like this..

- i put this on my form, which it was buton1, button2, Exit button and the webbrowser control
- when button1 was pressed it will show my "C:\Program Files\" directory on the webbrowser
- when buton2 was pressed it will load a "www.google.com" url on my webbrowser
- i disable the context menu by set it to false on my webbrowser properties at "IsWebBrowserContextMenuEnable"

so i can't right click on the webbrowser anymore, but this only done when i pressed button2 and not button1 which is my "C:\Program Files\" directory.

so my question is how i can disable completely this right click features on my webbrowser even on my whole project? hope someone can answer my question
PraDevil[ELITE] is offline  
Old 01/13/2012, 00:32   #2
 
RebeccaBlack's Avatar
 
elite*gold: 0
Join Date: Sep 2010
Posts: 520
Received Thanks: 1,289
I found this:

Code:
using System;
using System.Windows.Forms;

namespace WindowsApplication1 {
  public partial class Form1 : Form, IMessageFilter {
    public Form1() {
      InitializeComponent();
      Application.AddMessageFilter(this);
      this.FormClosed += new FormClosedEventHandler(this.Form1_FormClosed);
    }
    private void Form1_FormClosed(object sender, FormClosedEventArgs e) {
      Application.RemoveMessageFilter(this);
    }
    public bool PreFilterMessage(ref Message m) {
      // Filter out WM_NCRBUTTONDOWN/UP/DBLCLK
      if (m.Msg == 0xA4 || m.Msg == 0xA5 || m.Msg == 0xA6) return true;
      // Filter out WM_RBUTTONDOWN/UP/DBLCLK
      if (m.Msg == 0x204 || m.Msg == 0x205 || m.Msg == 0x206) return true;
      return false;
    }
  }
}
RebeccaBlack is offline  
Thanks
1 User
Old 01/15/2012, 06:11   #3
 
PraDevil[ELITE]'s Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 1,486
Received Thanks: 919
sorry rebecca, im was using vb not c#
it would be great if you can post for vb too.
PraDevil[ELITE] is offline  
Old 01/15/2012, 11:22   #4
 
Jay Niize's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 4,851
Received Thanks: 3,417
You can convert it from C# to Vb.net. (:

Code:
Imports System
Imports System.Windows.Forms

Namespace WindowsApplication1
     
     Public Class Form1
         Inherits Form
         Implements IMessageFilter
         
         Public Sub New()
             MyBase.New
             InitializeComponent
             Application.AddMessageFilter(Me)
             AddHandler FormClosed, AddressOf Me.Form1_FormClosed
         End Sub
         
         Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As FormClosedEventArgs)
             Application.RemoveMessageFilter(Me)
         End Sub
         
         Public Function PreFilterMessage(ByRef m As Message) As Boolean
             ' Filter out WM_NCRBUTTONDOWN/UP/DBLCLK
             If ((m.Msg = 164)  _
                         OrElse ((m.Msg = 165)  _
                         OrElse (m.Msg = 166))) Then
                 Return true
             End If
             ' Filter out WM_RBUTTONDOWN/UP/DBLCLK
             If ((m.Msg = 516)  _
                         OrElse ((m.Msg = 517)  _
                         OrElse (m.Msg = 518))) Then
                 Return true
             End If
             Return false
         End Function
     End Class
 End Namespace
I've not tested it.
Jay Niize is offline  
Thanks
1 User
Old 01/15/2012, 15:09   #5
 
PraDevil[ELITE]'s Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 1,486
Received Thanks: 919
im not sure what's was im doing now(newbie lol)
i just copy and paste those code to the top of my form1.vb and get this error
Code:
Class 'Form1' must implement 'Function PreFilterMessage(ByRef m As Message) As Boolean' for interface 'System.Windows.Forms.IMessageFilter'.

Name 'InitializeComponent' is not declared.
did i must create new class then paste the code there? if yes how to call this function?
i'm dead playing with it >.<
PraDevil[ELITE] is offline  
Old 01/16/2012, 11:46   #6


 
Al Kappaccino's Avatar
 
elite*gold: 179
Join Date: Oct 2009
Posts: 7,853
Received Thanks: 8,558
Quote:
Originally Posted by PraDevil[ELITE] View Post
im not sure what's was im doing now(newbie lol)
i just copy and paste those code to the top of my form1.vb and get this error
Code:
Class 'Form1' must implement 'Function PreFilterMessage(ByRef m As Message) As Boolean' for interface 'System.Windows.Forms.IMessageFilter'.

Name 'InitializeComponent' is not declared.
did i must create new class then paste the code there? if yes how to call this function?
i'm dead playing with it >.<
Just tested it with some settings you told.

It should look like this:

Code:
Imports System
Imports System.Windows.Forms

Public Class Form1 : Implements IMessageFilter


    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        WebBrowser1.Navigate("www.google.de")
    End Sub

    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        WebBrowser1.Navigate("C:/")
    End Sub

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Application.AddMessageFilter(Me)
        AddHandler FormClosed, AddressOf Me.Form1_FormClosed
    End Sub

    Public Function PreFilterMessage(ByRef m As System.Windows.Forms.Message) As Boolean Implements System.Windows.Forms.IMessageFilter.PreFilterMessage
        
        If ((m.Msg = 164) _
                    OrElse ((m.Msg = 165) _
                    OrElse (m.Msg = 166))) Then
            Return True
        End If
  
        If ((m.Msg = 516) _
                    OrElse ((m.Msg = 517) _
                    OrElse (m.Msg = 518))) Then
            Return True
        End If
        Return False
    End Function

    Private Sub Form1_FormClosed(sender As System.Object, e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
        Application.RemoveMessageFilter(Me)
    End Sub

End Class
Al Kappaccino is offline  
Thanks
1 User
Old 01/16/2012, 17:27   #7
 
PraDevil[ELITE]'s Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 1,486
Received Thanks: 919
man, really thanks! its work <3
PraDevil[ELITE] is offline  
Old 01/21/2012, 21:15   #8
 
mrapc's Avatar
 
elite*gold: 238
Join Date: Sep 2009
Posts: 2,327
Received Thanks: 1,164
Bot the easyest way is when you choose in the OPtions Left at Webborwser1 -> Contextmenustript = ContextMenuStript1
mrapc is offline  
Reply


Similar Threads Similar Threads
Webbrowser
06/02/2011 - General Coding - 13 Replies
Hallo ich hab einen Webbrowser und will da nun so machen dass er die passwörter speichert. Wie geht das?
ImageUploader via Kontextmenü/Contextmenu
03/11/2011 - Coding Releases - 4 Replies
ImageUploader v2 German Dieses Tool erleichtert euch das uploaden eurer Bilder. Durch ein Rechtsklick auf euer zu uploadendes Bild öffnet sich das Kontextmenü. Dort auf "Senden an" -> "ImageUploader". Das Programm startet im Hintergrund, uploadet das Bild auf der von euch eingestellten Seite und kopiert den von euch gewünschten Link in die Zwischenablage.
VB.net WebBrowser
11/24/2009 - .NET Languages - 0 Replies
Hallo Leutz Nachdem ich mit WoW aufgehört habe, wollte ich malwieder ein bssl. coden. Allerdings finde einfach keine Lösung, die folgende Tabelle auszulesen: <img src="img/x.gif" class="r1" alt="Holz" title="Holz"></td> <td id="l4" title="20">180/800</td> <td><img src="img/x.gif" class="r2" alt="Lehm" title="Lehm"></td> <td id="l3" title="24">165/800</td> <td><img src="img/x.gif" class="r3" alt="Eisen" title="Eisen"></td> <td id="l2" title="24">233/800</td>
NDS Webbrowser
10/08/2008 - Consoles - 4 Replies
Hallo liebe community habe da ein kleines Problem Der nds webbrowser(der richtige) läuft nicht richtig bei meiner supercard da steht immer ich muss ne ram erweiterung in slot 2 reintun aber ich habe keins da wollt ich fragen ob man nicht die micro sd karte als ram erweiterung benutzen könnte . Gibt es überhaupt gute homebrew browser für den ds (kein ds organize ) mfg Fatal3ty



All times are GMT +1. The time now is 14:06.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.