VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Creates a form with a ROUND corners!

by Stefan Schweter (2 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 10th June 2004
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Creates a form with a ROUND corners!

Rate Creates a form with a ROUND corners!



Private s_Y As Long
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 Command3_Click()
End
End Sub

Private Sub Form_Load()
 
  Command2.Enabled = False
End Sub


Private Sub Command1_Click()
  Dim Y As Long
  Dim n As Long
  
  X = Me.Width / Screen.TwipsPerPixelX
  Y = Me.Height / Screen.TwipsPerPixelY

  
  n = 120
  
  SetWindowRgn Me.hwnd, CreateRoundRectRgn(0, 0, X, Y, n, n), True
  
 
  Command1.Enabled = False
  
 
  Command2.Enabled = True
End Sub


Private Sub Command2_Click()
  Dim X As Long
  Dim Y As Long
  Dim n As Long
  
  X = Me.Width / Screen.TwipsPerPixelX
  Y = Me.Height / Screen.TwipsPerPixelY
  
  
  n = 0
  
  SetWindowRgn Me.hwnd, CreateRoundRectRgn(0, 0, X, Y, n, n), True
  
  
  Command1.Enabled = True
  
  
  Command2.Enabled = False
End Sub




Private Sub Form_MouseDown(Button As Integer, _
  Shift As Integer, X As Single, Y As Single)
  

  s_X = X: s_Y = Y
End Sub

Private Sub Form_MouseMove(Button As Integer, _
  Shift As Integer, X As Single, Y As Single)
  
  Dim lPos As Long
  
  If Button > 0 Then
   
    lPos = Me.Left + X - s_X
    If lPos < 350 Then lPos = 0
    If lPos > Screen.Width - 350 - Me.Width Then _
      lPos = Screen.Width - Me.Width
    Me.Left = lPos
    
    
    lPos = Me.Top + Y - s_Y
    If lPos < 350 Then lPos = 0
    If lPos > Screen.Height - 350 - Me.Height Then _
      lPos = Screen.Height - Me.Height
    Me.Top = lPos
  End If
End Sub
Private Sub cmdExit_Click()
  
  Unload Me
  End
End Sub






Download this snippet    Add to My Saved Code

Creates a form with a ROUND corners! Comments

No comments have been posted about Creates a form with a ROUND corners!. Why not be the first to post a comment about Creates a form with a ROUND corners!.

Post your comment

Subject:
Message:
0/1000 characters