Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

VB.NET Problem bei MousePosition

Empfohlene Antworten

Veröffentlicht

Hallo.

Ich schreibe gerade an einem Programm , bei dem ein ereignis passieren soll wenn man in eine bestimmte region klickt.

Im Moment sieht das bei mir so aus:


Public Class Form1


 Private Declare Function GetAsyncKeyState Lib "user32"_

 (ByVal vKey As Long) As Integer

   private Const VK_LBUTTON = &H1

   private Const VK_RBUTTON = &H2



dim mousex as integer = mouseposition.x

dim mousey as integer = mouseposition.y

dim reg as region 



...

Private Sub Form1_Mousemove (ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove


        mousex = e.X

        mousey = e.Y


End Sub


    Public Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick


        If GetAsyncKeyState(VK_LBUTTON) Then

            reg.IsVisible(mousex, mousey)

            MsgBox("TEST")

        End If


End Sub


End Class

Wenn Ich das programm starte und klicke kommt immer die Folgende Fehlermeldung: " Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt."

Was mache ich falsch?

Wie bekomme ich das zum funktionieren?

Sorry wenn das ne anfängerfrage ist, ich bin eben einer.

Schonmal Danke für eure Antworten

MfG Shogoki92

  • Autor

Sorry aber Irgendwie kann ich den Betrag nicht bearbeiten, der Code ist falsch hier der richtige, aber das Problem ist das selbe:

Public Class Form1


 Private Declare Function GetAsyncKeyState Lib "user32"_

 (ByVal vKey As Long) As Integer

   private Const VK_LBUTTON = &H1

   private Const VK_RBUTTON = &H2



dim mousex as integer = mouseposition.x

dim mousey as integer = mouseposition.y

dim reg as region 



...

    Private Sub Form1_Mousemove (ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove


        mousex = e.X

        mousey = e.Y


    End Sub


    Public Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick


        If GetAsyncKeyState(VK_LBUTTON) Then

            If reg.IsVisible(mousex, mousey) Then


            MsgBox("TEST")

            End if

        End If


    End Sub


End Class


Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.