Le réseau pour les développeurs > Forums - Accueil > Visual Basic General > Error: Value of type 'Integer' cannot be converted to
Poser une questionPoser une question
 

TraitéeError: Value of type 'Integer' cannot be converted to

  • samedi 7 novembre 2009 22:03Mark103 Médailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     A du code
    Hi guys,

    I have a problem, I cannot converted the value of Integer type, which it cannot converted to 'System.Drawing.Point' and 'System.Windows.Forms.Control' .



    Both errors is highlighting on this statement


    Form1.ContextMenu1.Show(Form1.MousePosition.X, MousePosition.Y)

    Error I have received which the errors is highlighting on MousePosition.X and MousePosition.Y statement:
    Value of type 'Integer' cannot be converted to 'System.Drawing.Point'
    Value of type 'Integer' cannot be converted to 'System.Windows.Forms.Control'.





    Class library code:

    Public Class NoRightClickFlashControl
        Inherits AxShockwaveFlashObjects.AxShockwaveFlash
        Private Const WM_RBUTTONDOWN As Integer = &H204
    
        Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
            Select Case m.Msg
                Case WM_RBUTTONDOWN
                    Form1.ContextMenu1.Show(Form1.MousePosition.X, MousePosition.Y)
                    m.Result = New IntPtr(1)
                    Return
            End Select
            MyBase.WndProc(m)
        End Sub
    End Class



    Form1 code:


    Public Class Form1
        Friend WithEvents ContextMenuStrip1 As System.Windows.Forms.ContextMenuStrip = New ContextMenuStrip
        Friend WithEvents PlayToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem = New ToolStripMenuItem
        Friend WithEvents StopToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem = New ToolStripMenuItem
        Friend WithEvents ForwardToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem = New ToolStripMenuItem
        Friend WithEvents ReverseToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem = New ToolStripMenuItem
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        End Sub
    End Class






    Please can you help me to solution the errors I have received on form1.contextmenu1.show statement??



    Thanks,
    Mark

Réponses

  • samedi 7 novembre 2009 23:18Acamar Médailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     Traitée

    It appears that you are trying to get the contextmenu to appear at the position the user has right clicked the mouse on the form.  You do no need code to get the context menu to appear - simply set the form's context menu property to the context menu that you want to appear, For instance:

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Me.ContextMenuStrip = ContextMenuStrip1
    End Sub

    Or, you could set that property in the desinger.

    • Marqué comme réponseMark103 samedi 7 novembre 2009 23:31
    •  

Toutes les réponses

  • samedi 7 novembre 2009 22:18DJ PIP Médailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     A du code
    Change this line  ....

    Form1.ContextMenu1.Show(Form1.MousePosition.X, MousePosition.Y)
     ... to ...
    Form1.ContextMenu1.Location = New Point(MousePosition.X, MousePosition.Y)
    Form1.ContextMenu1.Show()

    DJ PIP
  • samedi 7 novembre 2009 22:25Mark103 Médailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     A du code
    Thanks for this, but I have received two errors in each line.


    With this line:
    Form1.ContextMenu1.Show()
    Error: Overload resolution failed because no accessible 'Show' accepts this number of arguments.


    And this line:
    Form1.ContextMenu1.Location = New Point(MousePosition.X, MousePosition.Y)
    Error: 'Location' is not a member of 'System.Windows.Forms.ContextMenu'.



    Please can you help to fix this??


    Thanks,
    Mark
  • samedi 7 novembre 2009 23:18Acamar Médailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     Traitée

    It appears that you are trying to get the contextmenu to appear at the position the user has right clicked the mouse on the form.  You do no need code to get the context menu to appear - simply set the form's context menu property to the context menu that you want to appear, For instance:

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Me.ContextMenuStrip = ContextMenuStrip1
    End Sub

    Or, you could set that property in the desinger.

    • Marqué comme réponseMark103 samedi 7 novembre 2009 23:31
    •