| |
VB.NET - FortgeschritteneRe: NativeWindow WndProc Maus | | | Autor: Mary | Datum: 10.12.03 22:02 |
| Sori bin den falschen weg gegangen.
Für alle die so etwas interessiert.
Am Classanfang irgendwo
API
<StructLayout(LayoutKind.Sequential)> _
Public Structure RECT
Public Left As Int32
Public Top As Int32
Public Right As Int32
Public Bottom As Int32
End Structure
<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
Public Shared Function MoveWindow(ByVal hwnd As Int32, _
ByVal x As Int32, ByVal y As Int32, ByVal nWidth As Int32, _
ByVal nHeight As Int32, ByVal bRepaint As Int32) As Int32
End Function
<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
Public Shared Function InvalidateRect(ByVal hwnd As Int32, _
ByRef lpRect As Win32.RECT, ByVal bErase As Int32) As Int32
End Function
Protected _Form As Rectangle
Private Sub SetWindowRegion()
User32.MoveWindow(Me.Handle.ToInt32, _Form.X, _Form.Y, _Form.Width, _Form.Height, 1)
Dim clientRect As New Win32.RECT
clientRect.Left = 0
clientRect.Top = 0
clientRect.Right = _Form.Width
clientRect.Bottom = _Form.Height
User32.InvalidateRect(Me.Handle.ToInt32, clientRect, 1) ‘1 = True
End Sub
……
<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
Public Shared Function GetCursorPos(ByRef lpPoint As POINTAPI) As Int32
End Function
<StructLayout(LayoutKind.Sequential)> _
Public Structure POINTAPI
Public x As Int32
Public y As Int32
End Structure
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Select Case m.Msg
Case Win32.Msgs.WM_MOUSEMOVE
ClientPosition()
Exit Select
End Select
MyBase.WndProc(m) ‘Wichtig Sonst Crech
End Sub
Protected Sub ClientPosition()
Dim Pos As Point
Dim wPos As Win32.POINTAPI
User32.GetCursorPos(wPos)
Pos.X = CInt(wPos.x - _Form.X)
Pos.Y = CInt(wPos.y - _Form.Y)
und man hat genau die Maus-Koordinaten
…… | |
| Sie sind nicht angemeldet! Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.
Einloggen | Neu registrieren |
|
|
Neu! sevEingabe 3.0
Einfach stark!
Ein einziges Eingabe-Control für alle benötigten Eingabetypen und -formate, inkl. Kalender-, Taschenrechner und Floskelfunktion, mehrspaltige ComboBox mit DB-Anbindung, ImageComboBox u.v.m. Weitere InfosTipp des Monats Access-Tools Vol.1
Über 400 MByte Inhalt
Mehr als 250 Access-Beispiele, 25 Add-Ins und ActiveX-Komponenten, 16 VB-Projekt inkl. Source, mehr als 320 Tipps & Tricks für Access und VB
Nur 24,95 EURWeitere Infos
|
|
|
Copyright ©2000-2024 vb@rchiv Dieter Otter Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.
Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel
|
|