EK1 Posted October 14, 2003 Posted October 14, 2003 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 Quote
Administrators PlausiblyDamp Posted October 14, 2003 Administrators Posted October 14, 2003 What should it do? I ran it and it did nothing - although the call to DrawFramControl did return a value indicating it had failed Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
*Experts* Volte Posted October 14, 2003 *Experts* Posted October 14, 2003 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. Quote
*Gurus* divil Posted October 14, 2003 *Gurus* Posted October 14, 2003 Also, the various methods of the ControlPaint class are designed to wrap the DrawFrameControl API, you should check it out. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.