Solved

Hiding/disabling context menu on mouseenter event

Posted on 2006-10-24
3
305 Views
Last Modified: 2008-02-01
Hello

I have 2 buttons index_futures and index_options...index_futures_cm and index_options_cm are the two context menus assocaited with them

When I 'mouseenter' index_futures index_futures_cm pops up. However now when I enter index_options its associated contextmenu wont pop up i.e no mouseneter event is triggered

Here is the code

  Private Sub index_futures_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles index_futures.MouseEnter

        index_futures.BackColor = Color.DarkBlue
        index_futures.ForeColor = Color.White

        index_options.BackColor = Color.WhiteSmoke
        index_options.ForeColor = Color.Black

        pos = New Point(index_futures.Width + 1)
        index_futures_cm.Show(index_futures, pos)
        '  index_futures.BackColor = Color.DarkBlue
        ' index_futures.ForeColor = Color.White


    End Sub

 Private Sub index_options_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles index_options.MouseEnter

        index_options.BackColor = Color.DarkBlue
        index_options.ForeColor = Color.White

        index_futures.BackColor = Color.WhiteSmoke
        index_futures.ForeColor = Color.Black

        pos = New Point(index_options.Width + 1)
        index_options_cm.Show(index_options, pos)


    End Sub


In a nutshell, I want to hide the context menu on mouseenter event and not a mouseclick event.
I know this is against the general implemetation of a menu, but I am trying to replicate a menu similar to the "programs" "documents" seen on the left of the windows

thank you...please let me know asap as this is super urgent....i had posted the thread by mistake in C++ region and there has been enough delay
0
Comment
Question by:jbajaj
3 Comments
 
LVL 9

Expert Comment

by:DjDezmond
ID: 17794364
Im not sure what you mean? You want to hide the context menu? Then delete the code from the sub...? You have posted no code for your mouse_enter event?

Can you explain again?
0
 
LVL 9

Accepted Solution

by:
Naveen Swamy earned 500 total points
ID: 17795015
0
 

Author Comment

by:jbajaj
ID: 17827281
Hello

I tried using IMessageFilter to do the same. I still cant . Please find my code below. If I enter button2 I should be able hide the context menu related to button1. Can someone please help asap

Imports System.Text
Imports System
Imports System.Data
Imports System.Drawing
Imports System.Windows.Forms


Public Class Form1
    Inherits System.Windows.Forms.Form
    Implements IMessageFilter

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()
        Application.AddMessageFilter(Me)
        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

 
#End region



    Dim pos As Point

   



    ' Discard mouse messages waiting to be processed
    '
    ' This procedure is sometimes useful to prevent VB
    ' from processing spurious mouse clicks


    'This method is called by the system for all messages
    Public Function PreFilterMessage(ByRef m As System.Windows.Forms.Message) As Boolean _
        Implements System.Windows.Forms.IMessageFilter.PreFilterMessage

        If Not Me.IsDisposed Then
            'reset the clock here for any input you would like to test for
            Const WM_LBUTTONDOWN = &H201
            Const WM_RBUTTONDOWN = &H204
            Const WM_KEYDOWN = &H100
            Const QS_MOUSEMOVE = &H200

            Select Case m.Msg
                Case WM_LBUTTONDOWN, WM_RBUTTONDOWN, QS_MOUSEMOVE
                    resetClock("Mouse")
                Case WM_KEYDOWN
                    resetClock("KeyPress")
                    'Case QS_MOUSEMOVE
                    '   resetClock("mousemove")
            End Select

            'pass the message on to the form
            Return False
        End If



    End Function


    Private Sub resetClock(ByVal method As String)
        'you would actually reset your timer method here
        'Just output to debug for illustration
        Debug.WriteLine(method & " reset me " & Now & Cursor.Position.X & Cursor.Position.Y)
        'MessageBox.Show(method & " reset me " & Now)
        ' SendKeys.Send("{ESC}")

        '  WindowFromMouse()


    End Sub



    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.MouseEnter
        pos = New Point(Button1.Width + 1)
        ContextMenu1.Show(Button1, pos)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.MouseEnter

        pos = New Point(Button2.Width + 1)
        ContextMenu2.Show(Button2, pos)
    End Sub

    Private Sub contextMenu1_Popup(ByVal sender As Object, ByVal e As System.EventArgs) Handles ContextMenu1.Popup

    End Sub
 
End Class
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now