For those Who Like Clocks. : )

Discussion in 'Visual Basic [VB]' started by Aether, Feb 22, 2006.

  1. Aether

    Aether New Member

    Joined:
    Feb 20, 2006
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    I Am Fifteen. :|
    Location:
    -=()N-=()=-C()=-
    Home Page:
    http://www.s3rial-3xperiments.net.ms
    Here is a good code for you all. Toss it in a black form, and make all text lime green. K?
    It Is A Big Code. Here Are Your Objects:
    8 labels(label1-label8)
    3 Timers(timer1-timer3)
    and two textboxes(text1 is disabled on formload, please.. :) text2 enabled always....)

    --------------------------------------------------------------------------------------
    Code:
    Const LWA_COLORKEY = &H1
    Const LWA_ALPHA = &H2
    Const GWL_EXSTYLE = (-20)
    Const WS_EX_LAYERED = &H80000
    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
    
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    Private MouseDownForm
    Private MouseDownFormX
    Private MouseDownFormY
    Private Type POINTAPI
        X As Long
        Y As Long
    End Type
    
    Private Sub Form_Load()
    Timer1.Enabled = True
    Label2.Caption = "Turn Off"                                               'You'll Get A Kick Outta The 
        Dim Ret As Long                                                           'Form load. its hawt.
        Ret = GetWindowLong(Me.hWnd, GWL_EXSTYLE)
        Ret = Ret Or WS_EX_LAYERED
        SetWindowLong Me.hWnd, GWL_EXSTYLE, Ret
        Me.Width = 0 'Starting Size Can Be Changed To What You Want
        Me.Height = 0
        Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2
        Timer3.Enabled = True
    
    End Sub
    
    
    
    Private Sub Label1_Change()           'This is for when the alarm is active.
    If Text1.Enabled = True Then
    If Label1.Caption = Text1.Text & Text2.Text Then
    Timer2.Enabled = True
    End If
    End If
    End Sub
    
    Private Sub Label2_Click()  'Turns off clock. (Label Caption = Turn Off)
    If Label2.Caption = "Turn Off" Then
    Timer1.Enabled = False
    Label3.Caption = "Turn On"
    End If
    End Sub
    
    Private Sub Label3_Click()           'Turns on clock(Turn On)
    If Label2.Caption = "Turn Off" Then
    Timer1.Enabled = True
    End If
    
    End Sub
    
    Private Sub Label4_Click() (Label caption is Enable Alarm)
    Text1.Enabled = True
    End Sub
    
    Private Sub Label5_Click()    'Disables alarm caption is Disable Alarm
    Timer2.Enabled = False
    Text1.Enabled = False
    End Sub
    
    Private Sub Label7_Click()    'End Program caption is X
    End
    End Sub
    
    Private Sub Label8_Click()         ' Minimizes & caption = ____
    Form1.WindowState = vbMinimized
    End Sub
    
    Private Sub Text1_Click()          'Clears text
    Text1.Text = ""
    End Sub
    Private Sub Text2_Click()     'Changes from AM to PM
    Text2.Text = " PM"
    End Sub
    Private Sub Text2_DblClick()   'Changes from Pm to Am
    Text2.Text = " AM"
    End Sub
    Private Sub Timer1_Timer()    ' Makes label1 show the time
    Label1.Caption = Time
    
    End Sub
    
    Private Sub Timer2_Timer()   ' The Alarm
    Beep
    End Sub
    Private Sub form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As     Single)    'Move The Form On Form1_Mousedown
    MouseDownForm = 1
    MouseDownFormX = X
    MouseDownFormY = Y
    End Sub
    Private Sub form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) ' Ends Moving The Form
    MouseDownForm = 0
    End Sub
    Private Sub form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As  Single)           'More Form movement
    If MouseDownForm <> 1 Then
    Exit Sub
    End If
    Dim Z As POINTAPI
    Call GetCursorPos(Z)
    Form1.Top = (Z.Y * 15) - MouseDownFormY
    Form1.Left = (Z.X * 15) - MouseDownFormX
    End Sub
    
    Private Sub Form_Activate()    'Form fades into view
    Dim Alpha As Byte
    Dim Delay As Single
    Do
        Delay = Timer
        Do While (Timer - Delay) < 0.01
            DoEvents
        Loop
        Alpha = Alpha + 1
        SetLayeredWindowAttributes Me.hWnd, 0, Alpha, LWA_ALPHA
    Loop Until Alpha = 255
    End Sub
    
    
    Private Sub Timer3_Timer()              'Form Sizes up as it loads.
        Me.Height = Me.Height + 18
             Me.Width = Me.Width + 150
        If Me.Width > 6350 Then  'Can be change accordingly
             Timer3.Enabled = False
        End If
        If Me.Height > 1000 Then
        Timer3.Enabled = False
        End If
        
    End Sub
    





    I Hope You All Like. : )
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
  3. Aether

    Aether New Member

    Joined:
    Feb 20, 2006
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    I Am Fifteen. :|
    Location:
    -=()N-=()=-C()=-
    Home Page:
    http://www.s3rial-3xperiments.net.ms
    Sorry... Lol.. Didn't See The Section.. I Guess At this Time Of Night My Eyes Sorta Go All Outta Whack On Me.. Sorta Like Almost Being Blind..... Lol>!
    But yah, enjoy : )
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Thats understable by a fellow programmer.
     
  5. Aether

    Aether New Member

    Joined:
    Feb 20, 2006
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    I Am Fifteen. :|
    Location:
    -=()N-=()=-C()=-
    Home Page:
    http://www.s3rial-3xperiments.net.ms
    : )
    ------------Alas-----------------
    -Someone Who Understands-
    -That Alone Is Worth 10000--
    -Thanks . : P -----------------
    ----------------------------------
     
  6. coderzone

    coderzone Super Moderator

    Joined:
    Jul 25, 2004
    Messages:
    736
    Likes Received:
    38
    Trophy Points:
    28
    Really a nice one.
     
  7. Saket

    Saket New Member

    Joined:
    Jul 21, 2009
    Messages:
    42
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Don't Know
    Thanks for the code.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice