![]() ![]() |
![]() |
![]() ![]() ![]() ![]() |
Home » Programming » Visual Basic » Regions [Sept, 21 1999] |
Prologue |
Platform : VB 6.
Have you ever wanted to make a form that's not rectangle like the above example? well, it's still a rectangle but it has rounded corner =) (I made it rounded rectangle because I hate the look oh ellipse windows). To make such Form in Visual Basic requires API calls. Following codes will show one way to do it. You can actually make Polygon form. But it'll be in different article =). This one only show to create a form with three rounded rectangle region.
|
Implementation |
Option
Explicit 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 Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, _ ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, _ ByVal nCombineMode As Long) As Long Private Const RGN_OR = 2 Private m_Rgn1 As Long Private m_Rgn2 As Long Private m_Rgn3 As Long Private m_Rgn As Long Private Sub Form_Load() Dim result As Long m_Rgn = CreateRoundRectRgn(25, 13, 487, 378, 20, 20) m_Rgn1 = CreateRoundRectRgn(25, 13, 487, 378, 20, 20) m_Rgn2 = CreateRoundRectRgn(0, 216, 62, 351, 20, 20) m_Rgn3 = CreateRoundRectRgn(413, 0, 546, 42, 20, 20) result = CombineRgn(m_Rgn, m_Rgn1, m_Rgn2, RGN_OR) result = CombineRgn(m_Rgn1, m_Rgn, m_Rgn3, RGN_OR) SetWindowRgn Me.hWnd, m_Rgn1, True End Sub |
Epilogue |
The code will not work nicely without proper settings. Fell free to download the sample projects. |
Home | inHere | Products | Projects
| Programming Stuff Copyright © 1999 AdNet®. All rights reserved. AdNet® is registered to Benni Adham. |