ZooFlow: Remove ClassWin32, replace with Modules.Windows

This commit is contained in:
Jonathan Jenne
2021-10-26 11:29:11 +02:00
parent 2b6e06c3fa
commit 0197835eee
5 changed files with 42 additions and 126 deletions

View File

@@ -1,116 +0,0 @@
Imports System.Runtime.InteropServices
Public Class ClassWin32
Public Const ULW_COLORKEY As Int32 = &H1
Public Const ULW_ALPHA As Int32 = &H2
Public Const ULW_OPAQUE As Int32 = &H4
Public Const AC_SRC_OVER As Byte = &H0
Public Const AC_SRC_ALPHA As Byte = &H1
Public Const WM_NCLBUTTONDOWN As Integer = &HA1
Public Const HTCAPTION As Integer = &H2
Public Const WM_DRAWCLIPBOARD As Integer = &H308
Public Enum Bool
[False] = 0
[True]
End Enum
<StructLayout(LayoutKind.Sequential)>
Public Structure WINDOWPOS
Public hwnd As IntPtr
Public hwndInsertAfter As IntPtr
Public x As Integer
Public y As Integer
Public cx As Integer
Public cy As Integer
Public flags As Integer
End Structure
<StructLayout(LayoutKind.Sequential)>
Public Structure Point
Public x As Int32
Public y As Int32
Public Sub New(ByVal x As Int32, ByVal y As Int32)
Me.x = x
Me.y = y
End Sub
End Structure
<StructLayout(LayoutKind.Sequential)>
Public Structure Size
Public cx As Int32
Public cy As Int32
Public Sub New(ByVal cx As Int32, ByVal cy As Int32)
Me.cx = cx
Me.cy = cy
End Sub
End Structure
<StructLayout(LayoutKind.Sequential, Pack:=1)>
Structure ARGB
Public Blue As Byte
Public Green As Byte
Public Red As Byte
Public Alpha As Byte
End Structure
<StructLayout(LayoutKind.Sequential, Pack:=1)>
Public Structure BLENDFUNCTION
Public BlendOp As Byte
Public BlendFlags As Byte
Public SourceConstantAlpha As Byte
Public AlphaFormat As Byte
End Structure
<DllImport("user32.dll", ExactSpelling:=True, SetLastError:=True)>
Public Shared Function UpdateLayeredWindow(ByVal hwnd As IntPtr, ByVal hdcDst As IntPtr, ByRef pptDst As Point, ByRef psize As Size, ByVal hdcSrc As IntPtr, ByRef pprSrc As Point, ByVal crKey As Int32, ByRef pblend As BLENDFUNCTION, ByVal dwFlags As Int32) As Bool
End Function
<DllImport("user32.dll", ExactSpelling:=True, SetLastError:=True)>
Public Shared Function GetDC(ByVal hWnd As IntPtr) As IntPtr
End Function
<DllImport("user32.dll", ExactSpelling:=True)>
Public Shared Function ReleaseDC(ByVal hWnd As IntPtr, ByVal hDC As IntPtr) As Integer
End Function
<DllImport("gdi32.dll", ExactSpelling:=True, SetLastError:=True)>
Public Shared Function CreateCompatibleDC(ByVal hDC As IntPtr) As IntPtr
End Function
<DllImport("gdi32.dll", ExactSpelling:=True, SetLastError:=True)>
Public Shared Function DeleteDC(ByVal hdc As IntPtr) As Bool
End Function
<DllImport("gdi32.dll", ExactSpelling:=True)>
Public Shared Function SelectObject(ByVal hDC As IntPtr, ByVal hObject As IntPtr) As IntPtr
End Function
<DllImport("gdi32.dll", ExactSpelling:=True, SetLastError:=True)>
Public Shared Function DeleteObject(ByVal hObject As IntPtr) As Bool
End Function
<DllImport("User32.dll")>
Public Shared Function ReleaseCapture() As Boolean
End Function
<DllImport("User32.dll")>
Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
End Function
<DllImport("user32", EntryPoint:="AddClipboardFormatListener")>
Public Shared Function AddClipboardFormatListener(ByVal hWnd As IntPtr) As Boolean
End Function
<DllImport("user32", EntryPoint:="RemoveClipboardFormatListener")>
Public Shared Function RemoveClipboardFormatListener(ByVal hWnd As IntPtr) As Boolean
End Function
<DllImport("user32", EntryPoint:="SetClipboardViewer")>
Public Shared Function SetClipboardViewer(ByVal hWnd As IntPtr) As IntPtr
End Function
End Class

View File

@@ -1,4 +1,5 @@
Imports System.Runtime.InteropServices
Imports DigitalData.Modules.Windows
Namespace ClipboardWatcher
Public Class Watcher
@@ -12,12 +13,12 @@ Namespace ClipboardWatcher
Private Sub New()
MyBase.CreateHandle(New CreateParams)
_Handle = ClassWin32.SetClipboardViewer(Handle)
_Handle = NativeMethods.SetClipboardViewer(Handle)
End Sub
Protected Overrides Sub WndProc(ByRef m As Message)
Select Case m.Msg
Case ClassWin32.WM_DRAWCLIPBOARD
Case NativeMethods.WM_DRAWCLIPBOARD
Dim oData As IDataObject = Clipboard.GetDataObject
RaiseEvent ClipboardChanged(Me, oData)
End Select
@@ -38,7 +39,7 @@ Namespace ClipboardWatcher
' aufgerufen werden
End If
MyBase.DestroyHandle()
Dim H As IntPtr = ClassWin32.SetClipboardViewer(_Handle)
Dim H As IntPtr = NativeMethods.SetClipboardViewer(_Handle)
End If
_DisposedValue = True
End Sub

View File

@@ -246,7 +246,6 @@
<Compile Include="Globix\ClassFilehandle.vb" />
<Compile Include="ClassInit.vb" />
<Compile Include="ClassLayout.vb" />
<Compile Include="ClassWin32.vb" />
<Compile Include="ClipboardWatcher\State.vb" />
<Compile Include="ClassIDBData.vb" />
<Compile Include="DSIDB_Stammdaten.Designer.vb">

View File

@@ -104,9 +104,8 @@ Public Class frmFlowForm
Try
' Marshal the LPARAM value which is a WINDOWPOS struct
Dim NewPosition As New ClassWin32.WINDOWPOS
NewPosition = CType(Marshal.PtrToStructure(
LParam, GetType(ClassWin32.WINDOWPOS)), ClassWin32.WINDOWPOS)
Dim NewPosition As New NativeMethods.WINDOWPOS
NewPosition = CType(Marshal.PtrToStructure(LParam, GetType(NativeMethods.WINDOWPOS)), NativeMethods.WINDOWPOS)
If NewPosition.y = 0 OrElse NewPosition.x = 0 Then
Return ' Nothing to do!
@@ -372,8 +371,8 @@ Public Class frmFlowForm
Private Sub frmFlowForm_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles Me.MouseMove, PictureBoxDragDrop.MouseMove
If e.Button = MouseButtons.Left Then
ClassWin32.ReleaseCapture()
ClassWin32.SendMessage(Handle, ClassWin32.WM_NCLBUTTONDOWN, ClassWin32.HTCAPTION, 0)
NativeMethods.ReleaseCapture()
NativeMethods.SendMessage(Handle, NativeMethods.WM_NCLBUTTONDOWN, NativeMethods.HTCAPTION, 0)
End If
End Sub