Results 1 to 3 of 3

Thread: Round Colorful Forms

  1. #1

    Thread Starter
    Registered User
    Join Date
    Mar 2018
    Posts
    1

    Round Colorful Forms

    Ok in its raw form this is really quite useless but it contains several interesting parts that can be put to greater use

    With this code you can create a round, color changing form that can be moved freely.

    Thank you SamOscarBrown for your circle code and Microsoft for helping me get the form movable

    you will need a form with a text box and a timer. I named the form frmRound

    seeing it work really blew my mind!
    PHP Code:
    Private Declare Function SendMessage Lib "User32" _
                             Alias 
    "SendMessageA" (ByVal hWnd As Long_
                                                   ByVal wMsg 
    As Long_
                                                   ByVal wParam 
    As Long_
                                                   lParam 
    As Any) As Long
    Private Declare Sub ReleaseCapture Lib "User32" ()

          Const 
    WM_NCLBUTTONDOWN = &HA1
          
    Const HTCAPTION 2

        Option Explicit
        
    Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As LongByVal Y1 As LongByVal X2 As LongByVal Y2 As Long) As Long
        
    Private Declare Function SetWindowRgn Lib "User32" (ByVal hWnd As LongByVal hRgn As LongByVal bRedraw As Long) As Long
       

        
    Private Sub Form_MouseMove(Button As IntegerShift As Integer_
                                     X 
    As SingleAs Single)
             
    Dim lngReturnValue As Long

             
    If Button 1 Then
                Call ReleaseCapture
                lngReturnValue 
    SendMessage(frmRound.hWndWM_NCLBUTTONDOWN_
                                             HTCAPTION
    0&)
             
    End If
          
    End Sub

        
    Private Sub Form_DblClick()
           
    Unload Me
        End Sub
        
    Private Sub Form_Load()
            
    Dim lngRegion As Long
            Dim lngReturn 
    As Long
            Dim lngFormWidth 
    As Long
            Dim lngFormHeight 
    As Long
            Me
    .Width Me.Height
            
            lngFormWidth 
    Me.Width Screen.TwipsPerPixelX
            lngFormHeight 
    Me.Height Screen.TwipsPerPixelY
            lngRegion 
    CreateEllipticRgn(00lngFormWidthlngFormHeight)
            
    lngReturn SetWindowRgn(Me.hWndlngRegionTrue)
    Label1.Left = (Me.Width 2) - (Label1.Width 2)
    Label1.Top = (Me.Height 2) - (Label1.Height 2)
        
    End Sub
        
    Private Sub Label1_Click()
           
    Unload frmRound
        End Sub
        
    Private Sub Timer1_Timer()
      Static 
    iColor As Integer
      Select 
    Case iColor
      
    Case 0Me.BackColor RGB(25500)   ' Red
      Case 1: Me.BackColor = RGB(255, 165, 0) ' 
    Orange
      
    Case 2Me.BackColor RGB(2552550' Yellow
      Case 3: Me.BackColor = RGB(0, 128, 0)   ' 
    Green
      
    Case 4Me.BackColor RGB(00255)   ' Blue
      Case 5: Me.BackColor = RGB(128, 0, 128) ' 
    Purple
      End Select
      iColor 
    iColor 1
      
    If iColor 5 Then iColor 0
    End Sub 

  2. #2
    Frenzied Member
    Join Date
    Dec 2008
    Location
    Melbourne Australia
    Posts
    1,487

    Re: Round Colorful Forms

    My Kingdom for an attached project, or an image, or both

    Rob

  3. #3
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Round Colorful Forms

    Not sure why you'd need this stunt, but he already gave you the important parts. Too bad he follows the poor practice of w-i-i-i-de lines of code that make programs harder to maintain and cause a mess in a forum like this though.
    Attached Files Attached Files

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