I used to change the Form shape in VB 6.0 using the following code:
Private Declare Function CreateRoundRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long
Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Sub MakeRoundObject(objObject As Object, Value As Long)
Static lngHeight, lngLong, lngReturn, lngWidth As Long
lngWidth = objObject.Width / Screen.TwipsPerPixelX
lngHeight = objObject.Height / Screen.TwipsPerPixelY
SetWindowRgn objObject.hWnd, CreateRoundRectRgn(10, 50, lngWidth, lngHeight, Value + 10, Value), True
End Sub
Private Sub Form_Load()
Call MakeRoundObject(Form1, 50)
End Sub
In the same way I used VB.NET code as follows:
Imports Microsoft.VisualBasic.Compatibility
Public Class Form1
Private Declare Function CreateRoundRectRgn Lib "gdi32" (ByVal X1 As Integer, ByVal Y1 As Integer, ByVal X2 As Integer, ByVal Y2 As Integer, ByVal X3 As Integer, ByVal Y3 As Integer) As Integer
Private Declare Function ReleaseCapture Lib "user32" () As Integer
Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Integer, ByVal hRgn As Integer, ByVal bRedraw As Boolean) As Integer
Private Sub MakeRoundObject(ByRef objObject As Object, ByRef Value As Integer)
Static lngLong, lngHeight, lngReturn As Object
Static lngWidth As Integer
lngWidth = objObject.Width / VB6.TwipsPerPixelX
lngHeight = objObject.Height / VB6.TwipsPerPixelY
SetWindowRgn(objObject.hWnd, CreateRoundRectRgn(0, 0, lngWidth, lngHeight, Value, Value), True)
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
MakeRoundObject(Me, 20)
End Sub
End Class
But in the latter case, I receive an error message - "Public member 'hWnd' on type 'Form1' not found."
What I do?