⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ex6.frm

📁 This assignment requires you to complete the dynamic drawing components of the Date/Time Control Pan
💻 FRM
📖 第 1 页 / 共 2 页
字号:
    timeZone(8) = "(GMT -06:00) Mexico City, Tegucigalpa "
    timeZone(9) = "(GMT -06:00) Saskatchewan"
    timeZone(10) = "(GMT -05:00) Bogota, Lima"
    timeZone(11) = "(GMT -05:00) Eastern Time (US and Canada)"
    timeZone(12) = "(GMT -05:00) Indiana (East)"
    timeZone(13) = "(GMT -04:00) Atlantic Time (Canada)"
    timeZone(14) = "(GMT -04:00) Caracas, La Paz"
    timeZone(15) = "(GMT -03:30) Newfoundland"
    timeZone(16) = "(GMT -03:00) Brasilia"
    timeZone(17) = "(GMT -03:00) Buenos Aires, Georgetown"
    timeZone(18) = "(GMT -02:00) Mid-Atlantic"
    timeZone(19) = "(GMT -01:00) Azores, Cape Verde Is"
    timeZone(20) = "(GMT +00:00) Greenwich Mean Time; Dublin, Edinburgh, London, Lisbon"
    timeZone(21) = "(GMT +00:00) Monrovia, Casablanca"
    timeZone(22) = "(GMT +01:00) Berlin, Stockhold, Rome, Bern, Brussels, Vienna"
    timeZone(23) = "(GMT +01:00) Paris, Madrid, Amsterdam"
    timeZone(24) = "(GMT +01:00) Prage, Warsaw, Budapest"
    timeZone(25) = "(GMT +02:00) Athens, Helsinki, Istanbul"
    timeZone(26) = "(GMT +02:00) Cairo"
    timeZone(27) = "(GMT +02:00) Eastern Europe"
    timeZone(28) = "(GMT +02:00) Harare, Pretoria"
    timeZone(29) = "(GMT +02:00) Israel"
    timeZone(30) = "(GMT +03:00) Baghdad, Kuwait, Nairobi, Riyadh"
    timeZone(31) = "(GMT +03:00) Moscow, St. Petersburgh, Kazan, Volgograd"
    timeZone(32) = "(GMT +03:00) Tehran"
    timeZone(33) = "(GMT +04:00) Abu Dhabi, Muscat, Tbilisi"
    timeZone(34) = "(GMT +04:30) Kabul"
    timeZone(35) = "(GMT +05:00) Islamabad, Karachi, Ekaterinburg, Tashkent"
    timeZone(36) = "(GMT +05:30) Bombay, Calcutta, Madras, New Delhi, Colombo"
    timeZone(37) = "(GMT +06:00) Almaty, Dhaka"
    timeZone(38) = "(GMT +07:00) Bangkok, Jakarta, Hanoi"
    timeZone(39) = "(GMT +08:00) Beijing, Chongqing, Urumqi"
    timeZone(40) = "(GMT +08:00) Hong Kong, Perth, Singapore, Taipei"
    timeZone(41) = "(GMT +09:00) Tokyo, Osaka, Sapporo, Seoul, Yakutsk"
    timeZone(42) = "(GMT +09:30) Adelaide"
    timeZone(43) = "(GMT +09:30) Darwin"
    timeZone(44) = "(GMT +10:00) Brisbane, Melbourne, Sydney"
    timeZone(45) = "(GMT +10:00) Guam, Port Moresby, Vladivostok"
    timeZone(46) = "(GMT +10:00) Hobart"
    timeZone(47) = "(GMT +11:00) Magadan, Solomon Is., New Caledonia"
    timeZone(48) = "(GMT +12:00) Fiji, Kamchatka, Marshall Is"
    timeZone(49) = "(GMT +12:00) Wellington, Auckland"
    '添加时区到列表项
    For i = 0 To 49
        Combo1.AddItem timeZone(i), i
        hasSavingsTime(i) = True '对是否储存了时间负值
    Next i
    hasSavingsTime(0) = False   ' (GMT -12:00) Eniwetok, Kwajalein
    hasSavingsTime(1) = False   ' (GMT -11:00) Midway Island, Samoa
    hasSavingsTime(2) = False   ' (GMT -10:00) Hawaii
    hasSavingsTime(5) = False   '(GMT -07:00) Arizona
    hasSavingsTime(8) = False   ' (GMT -06:00) Mexico City, Tegucigalpa
    hasSavingsTime(9) = False   ' (GMT -06:00) Saskatchewan
    hasSavingsTime(10) = False  ' (GMT -05:00) Bogota, Lima
    hasSavingsTime(12) = False  ' (GMT -05:00) Indiana (East)
    hasSavingsTime(14) = False  ' (GMT -04:00) Caracas, La Paz
    hasSavingsTime(17) = False  ' (GMT -03:00) Buenos Aires, Georgetown
    hasSavingsTime(21) = False  ' (GMT +00:00) Monrovia, Casablanca
    hasSavingsTime(28) = False  ' (GMT +02:00) Harare, Pretoria
    hasSavingsTime(30) = False  ' (GMT +03:00) Baghdad, Kuwait, Nairobi, Riyadh
    hasSavingsTime(33) = False  ' (GMT +04:00) Abu Dhabi, Muscat, Tbilisi
    hasSavingsTime(34) = False  ' (GMT +04:30) Kabul
    hasSavingsTime(35) = False  ' (GMT +05:00) Islamabad, Karachi, Ekaterinburg, Tashkent
    hasSavingsTime(36) = False  ' (GMT +05:30) Bombay, Calcutta, Madras, New Delhi, Colombo
    hasSavingsTime(37) = False  ' (GMT +06:00) Almaty, Dhaka
    hasSavingsTime(38) = False  ' (GMT +07:00) Bangkok, Jakarta, Hanoi
    hasSavingsTime(40) = False  ' (GMT +08:00) Hong Kong, Perth, Singapore, Taipei
    hasSavingsTime(41) = False  ' (GMT +09:00) Tokyo, Osaka, Sapporo, Seoul, Yakutsk
    hasSavingsTime(43) = False  ' (GMT +09:30) Darwin
    hasSavingsTime(45) = False  ' (GMT +10:00) Guam, Port Moresby, Vladivostok
    hasSavingsTime(47) = False  ' (GMT +11:00) Magadan, Solomon Is., New Caledonia
    hasSavingsTime(48) = False  ' (GMT +12:00) Fiji, Kamchatka, Marshall Is.
    
    '对Time zone offsets in minutes 数组负值
    m(0) = "-720"
    m(1) = "-660"
    m(2) = "-600"
    m(3) = "-540"
    m(4) = "-480"
    m(5) = "-420"
    m(6) = "-420"
    m(7) = "-360"
    m(8) = "-360"
    m(9) = "-360"
    m(10) = "-300"
    m(11) = "-300"
    m(12) = "-300"
    m(13) = "-240"
    m(14) = "-240"
    m(15) = "-210"
    m(16) = "-180"
    m(17) = "-180"
    m(18) = "-120"
    m(19) = "-060"
    m(20) = "+000"
    m(21) = "+000"
    m(22) = "+060"
    m(23) = "+060"
    m(24) = "+060"
    m(25) = "+120"
    m(26) = "+120"
    m(27) = "+120"
    m(28) = "+120"
    m(29) = "+120"
    m(30) = "+180"
    m(31) = "+180"
    m(32) = "+180"
    m(33) = "+240"
    m(34) = "+270"
    m(35) = "+300"
    m(36) = "+330"
    m(37) = "+360"
    m(38) = "+420"
    m(39) = "+480"
    m(40) = "+480"
    m(41) = "+540"
    m(42) = "+570"
    m(43) = "+570"
    m(44) = "+600"
    m(45) = "+600"
    m(46) = "+600"
    m(47) = "+660"
    m(48) = "+720"
    m(49) = "+720"
    '显示初始化列表的内容
    Combo1.Text = Combo1.List(0)
    
    Combo1.ListIndex = 0
    Combo1.SelStart = 0
    Combo1.SelLength = Len(Combo1.Text)
    '读取当前的月份
    Calendar1.Month = Month(Now)
    '将当前月份显示出来
    Combo2.ListIndex = Calendar1.Month - 1
    '显示当前年份
    Text1.Text = Calendar1.Year
    '读取当前时间
    Text2.Text = Hour(Now)
    '读取当前的日期
    Calendar1.Day = Day(Now)
    '当选择了pm
    If Text2.Text > 12 Then
        Text2.Text = Text2.Text - 12
        Option2.Value = True
    Else
        Option1.Value = True
    End If
    '读取并显示当前分钟和秒钟
    Text3.Text = Minute(Now)
    Text4.Text = Second(Now)
    Command3.Enabled = False
    
    '时钟区域
    '时间按每秒计算
    Timer1.Interval = 1000
    '在picturebox3中画出60个点
    Picture3.AutoRedraw = True
    
    For minu = 0 To 59
        Call drawDotAtMinutes(Picture3, minu, vbGreen)
    Next minu
    
    For minu = 0 To 59 Step 5
       Call drawDotAtMinutes(Picture3, minu, vbBlack)
    Next minu
    '载入秒针
    radius = clockRadius - 100
    sec = Second(Now)
    secx = clockX(sec, radius)
    secy = clockY(sec, radius)

    Picture3.Line (Picture3.Width / 2, Picture3.Height / 2)-(secx, secy)
    
    '载入分针
    mradius = clockRadius - 100
    min = Minute(Now)
    minx = clockX(min, mradius)
    miny = clockY(min, mradius)
    mr1 = clockRadius - 1230
    mr1x = clockX(min + 15, mr1)
    mr1y = clockY(min + 15, mr1)
    mr2 = clockRadius - 1200
    mr2x = clockX(min + 30, mr2)
    mr2y = clockY(min + 30, mr2)
    mr3 = clockRadius - 1230
    mr3x = clockX(min + 45, mr3)
    mr3y = clockY(min + 45, mr3)
    
    '画分针的形状
    Picture3.Line (mr3x, mr3y)-(minx, miny), vbRed
    Picture3.Line (minx, miny)-(mr1x, mr1y), vbRed
    Picture3.Line (mr1x, mr1y)-(mr2x, mr2y), vbRed
    Picture3.Line (mr2x, mr2y)-(mr3x, mr3y), vbRed

    hBrush = CreateSolidBrush(RGB(255, 5, 5))
    hOldBrush = SelectObject(Picture3.hdc, hBrush)
    FloodFill Picture3.hdc, Picture3.Width / 2, Picture3.Height / 2, RGB(0, 0, 0)
    SelectObject Picture3.hdc, hOldBrush
    DeleteObject hBrush
    
    '载入时针
    hradius = clockRadius - 500
    hou = Text2.Text
    houx = clockX(hou * 5 + min / 12, hradius)
    houy = clockY(hou * 5 + min / 12, hradius)
    hr1 = clockRadius - 1230
    hr1x = clockX(hou * 5 + 15, hr1)
    hr1y = clockY(hou * 5 + 15, hr1)
    hr2 = clockRadius - 1200
    hr2x = clockX(hou * 5 + 30, hr2)
    hr2y = clockY(hou * 5 + 30, hr2)
    hr3 = clockRadius - 1230
    hr3x = clockX(hou * 5 + 45, hr3)
    hr3y = clockY(hou * 5 + 45, hr3)
    
    '画时针的形状
    Picture3.Line (hr3x, hr3y)-(houx, houy), vbRed
    Picture3.Line (houx, houy)-(hr1x, hr1y), vbRed
    Picture3.Line (hr1x, hr1y)-(hr2x, hr2y), vbRed
    Picture3.Line (hr2x, hr2y)-(hr3x, hr3y), vbRed
    

    hBrush = CreateSolidBrush(RGB(255, 5, 5))
    hOldBrush = SelectObject(Picture3.hdc, hBrush)
    FloodFill Picture3.hdc, Picture3.Width / 2, Picture3.Height / 2, RGB(0, 0, 0)
    SelectObject Picture3.hdc, hOldBrush
    DeleteObject hBrush

    
End Sub
Public Sub drawDotAtMinutes(onObj As PictureBox, min As Integer, color)
    Const clockInset As Integer = 100         ' distance from clock edge to box edge
    Const dotRadius As Integer = 15           ' size of the dot
    Dim smallDim As Integer                   ' smaller of width and height of box
                    ' radius of the clock
    Dim X As Integer                          ' x position of dot
    Dim Y As Integer                          ' y position of dot
    
    ' calculate the center of the clock and its radius so it fits in the box
    
    smallDim = onObj.Width
    If (onObj.Height < smallDim) Then
        smallDim = onObj.Height
    End If
    clockRadius = smallDim / 2 - clockInset
    ' calculate the position of the dot
    X = clockX(min, clockRadius - dotRadius)
    Y = clockY(min, clockRadius - dotRadius)
    ' draw a filled black circle
    onObj.FillStyle = 0 ' filled primitives
    onObj.FillColor = color
    onObj.Circle (X, Y), dotRadius, color
End Sub

Public Function clockX(minuteVal As Integer, radius As Integer)
    Const PI As Double = 3.14159265
    Dim angle As Double
    angle = (PI * 2 * minuteVal) / 60 - PI / 2
    clockX = CInt(radius * Cos(angle)) + Picture3.Width / 2
End Function
Public Function clockY(minuteVal As Integer, radius As Integer)
    Dim angle As Double
    Dim PI As Double
    PI = 3.14159265
    angle = (PI * 2 * minuteVal) / 60 - PI / 2
    clockY = CInt(radius * Sin(angle)) + Picture3.Height / 2
End Function


Private Sub Option1_Click()
    Command3.Enabled = True
End Sub

Private Sub Option2_Click()
    Command3.Enabled = True
End Sub

Private Sub Text1_Change()
    '年份改变
    Calendar1.Year = Text1.Text
    Command3.Enabled = True
End Sub

Private Sub Timer1_Timer()

    '时间随着流动
    Text2.Text = Hour(Time)
    If Text2.Text > 12 Then
        Text2.Text = Text2.Text - 12
        Option2.Value = True
    Else
        Option1.Value = True
    End If
    Text3.Text = Minute(Time)
    Text4.Text = Second(Time)
    
    Picture3.Cls
    
    '在picturebox3中画出60个点
    Picture3.AutoRedraw = True
    
    For minu = 0 To 59
        Call drawDotAtMinutes(Picture3, minu, vbGreen)
    Next minu
    
    For minu = 0 To 59 Step 5
       Call drawDotAtMinutes(Picture3, minu, vbBlack)
    Next minu
    
    radius = clockRadius - 100
    
    '画秒针
    
    sec = Second(Now)
    secx = clockX(sec, radius)
    secy = clockY(sec, radius)

    Picture3.Line (Picture3.Width / 2, Picture3.Height / 2)-(secx, secy)
    
    '画分针

    mradius = clockRadius - 100
    min = Minute(Now)
    minx = clockX(min, mradius)
    miny = clockY(min, mradius)
    mr1 = clockRadius - 1230
    mr1x = clockX(min + 15, mr1)
    mr1y = clockY(min + 15, mr1)
    mr2 = clockRadius - 1200
    mr2x = clockX(min + 30, mr2)
    mr2y = clockY(min + 30, mr2)
    mr3 = clockRadius - 1230
    mr3x = clockX(min + 45, mr3)
    mr3y = clockY(min + 45, mr3)
    
    
    Picture3.Line (mr3x, mr3y)-(minx, miny), vbRed
    Picture3.Line (minx, miny)-(mr1x, mr1y), vbRed
    Picture3.Line (mr1x, mr1y)-(mr2x, mr2y), vbRed
    Picture3.Line (mr2x, mr2y)-(mr3x, mr3y), vbRed
    
    
    hBrush = CreateSolidBrush(RGB(255, 5, 5))
    hOldBrush = SelectObject(Picture3.hdc, hBrush)
    FloodFill Picture3.hdc, Picture3.Width / 2, Picture3.Height / 2, RGB(0, 0, 0)
    SelectObject Picture3.hdc, hOldBrush
    DeleteObject hBrush
    
    '画时针
    hradius = clockRadius - 500
    hou = Text2.Text
    houx = clockX(hou * 5 + min / 12, hradius)
    houy = clockY(hou * 5 + min / 12, hradius)
    hr1 = clockRadius - 1230
    hr1x = clockX(hou * 5 + 15, hr1)
    hr1y = clockY(hou * 5 + 15, hr1)
    hr2 = clockRadius - 1200
    hr2x = clockX(hou * 5 + 30, hr2)
    hr2y = clockY(hou * 5 + 30, hr2)
    hr3 = clockRadius - 1230
    hr3x = clockX(hou * 5 + 45, hr3)
    hr3y = clockY(hou * 5 + 45, hr3)
    
    
    Picture3.Line (hr3x, hr3y)-(houx, houy), vbRed
    Picture3.Line (houx, houy)-(hr1x, hr1y), vbRed
    Picture3.Line (hr1x, hr1y)-(hr2x, hr2y), vbRed
    Picture3.Line (hr2x, hr2y)-(hr3x, hr3y), vbRed
   
    hBrush = CreateSolidBrush(RGB(255, 5, 5))
    hOldBrush = SelectObject(Picture3.hdc, hBrush)
    FloodFill Picture3.hdc, Picture3.Width / 2, Picture3.Height / 2, RGB(0, 0, 0)
    SelectObject Picture3.hdc, hOldBrush
    DeleteObject hBrush

    
End Sub

Private Sub UpDown1_DownClick()
    '年份减一
    Text1.Text = Text1.Text - 1
    Text1.SetFocus
    Command3.Enabled = True
End Sub

Private Sub UpDown1_UpClick()
    '年份加一
    Text1.Text = Text1.Text + 1
    Text1.SetFocus
    Command3.Enabled = True
End Sub

Private Sub UpDown2_DownClick()
    If Text2.Text > 1 Then
    Text2.Text = Text2.Text - 1
    End If
    Command3.Enabled = True
End Sub

Private Sub UpDown2_UpClick()
    If Text2.Text < 12 Then
    Text2.Text = Text2.Text + 1
    End If
    Command3.Enabled = True
End Sub

Private Sub UpDown3_DownClick()
    If Text3.Text > 0 Then
        Text3.Text = Text3.Text - 1
    End If
    Command3.Enabled = True
End Sub

Private Sub UpDown3_UpClick()
    If Text3.Text < 59 Then
        Text3.Text = Text3.Text + 1
    End If
    Command3.Enabled = True
End Sub

Private Sub UpDown4_DownClick()
    If Text4.Text > 0 Then
        Text4.Text = Text4.Text - 1
    End If
    Command3.Enabled = True
End Sub

Private Sub UpDown4_UpClick()
    If Text4.Text < 59 Then
        Text4.Text = Text4.Text + 1
    End If
    Command3.Enabled = True
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -