Results 1 to 3 of 3

Thread: Transparent forms

  1. #1
    Megatron
    Guest
    You should be able to make a round form without having to make the form transparent. Just use the CreateEllipticRgn API.

  2. #2
    Megatron
    Guest
    Here's a small example.
    VB Code:
    1. Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
    2. Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
    3. Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
    4. Private hRgn As Long
    5.  
    6. Private Sub Form_Load()
    7.     hRgn = CreateEllipticRgn(10, 10, 200, 200)
    8.     SetWindowRgn hWnd, hRgn, True
    9. End Sub
    10.  
    11. Private Sub Form_Unload(Cancel As Integer)
    12.     DeleteObject hRgn
    13. End Sub

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Here is what I use for round forms (I think they make very cool About boxes).
    VB Code:
    1. 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
    2. Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
    3. Private Declare Function DeleteObject Lib "gdi32.dll" (ByVal hObject As Long) As Long
    4. Private nhwnd As Long
    5. Private rval As Long
    6.  
    7. Private Sub Form_Load()
    8. Dim fwidth As Long, fheight As Long
    9.  
    10. fwidth = Me.Width / Screen.TwipsPerPixelX
    11. fheight = Me.Height / Screen.TwipsPerPixelY
    12. 'Create Round Rectangular Region
    13. nhwnd = CreateRoundRectRgn(0, 0, fwidth - 25, fheight - 25, fwidth - 50, fheight - 50)
    14. 'Set Round Rectangular Region on form
    15. rval = SetWindowRgn(Me.hWnd, nhwnd, True)
    16. End Sub
    17.  
    18. Private Sub Form_Unload(Cancel As Integer)
    19. rval = DeleteObject(nhwnd)
    20. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width