I saw this code posted on another forum but I cant get it to work. Can someone test this and see if it works for them?
Imports System.Runtime.InteropServices
Public Class Form1
Inherits System.Windows.Forms.Form
<StructLayout(LayoutKind.Sequential)> _
Public Structure rect
Dim left As Int64
Dim top As Int64
Dim right As Int64
Dim bottom As Int64
End Structure
Public Declare Function DrawFrameControl Lib "user32" (ByVal hDC As Int32, ByRef lpRect As IntPtr, ByVal un1 As Int32, ByVal un2 As Int32) As Int32
Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
Dim rectTest As rect
With rectTest
.left = 20
.top = 10
.right = 900
.bottom = 900
End With
Dim rectPointer As IntPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(rectTest))
Marshal.StructureToPtr(rectTest, rectPointer, True)
Dim myDC As System.Drawing.Graphics = Graphics.FromHwnd(Me.Handle)
Dim ptrHDC As IntPtr = myDC.GetHdc
Dim i As Int32 = DrawFrameControl(ptrHDC.ToInt32, rectPointer, 1, 2)
myDC.ReleaseHdc(ptrHDC)
myDC = Nothing
End Sub
End Class
Imports System.Runtime.InteropServices
Public Class Form1
Inherits System.Windows.Forms.Form
<StructLayout(LayoutKind.Sequential)> _
Public Structure rect
Dim left As Int64
Dim top As Int64
Dim right As Int64
Dim bottom As Int64
End Structure
Public Declare Function DrawFrameControl Lib "user32" (ByVal hDC As Int32, ByRef lpRect As IntPtr, ByVal un1 As Int32, ByVal un2 As Int32) As Int32
Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
Dim rectTest As rect
With rectTest
.left = 20
.top = 10
.right = 900
.bottom = 900
End With
Dim rectPointer As IntPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(rectTest))
Marshal.StructureToPtr(rectTest, rectPointer, True)
Dim myDC As System.Drawing.Graphics = Graphics.FromHwnd(Me.Handle)
Dim ptrHDC As IntPtr = myDC.GetHdc
Dim i As Int32 = DrawFrameControl(ptrHDC.ToInt32, rectPointer, 1, 2)
myDC.ReleaseHdc(ptrHDC)
myDC = Nothing
End Sub
End Class