Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I saw this code posted on another forum but I can't 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

  • *Experts*
Posted
You should use Int32s not Int64s. Longs in VB are 32-bit, while Longs in .NET are 64-bit, so you need to translate longs to ints when going from VB6 to .NET.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...