home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 6_2008-2009.ISO / data / zips / Calendar_c2220312192012.psc / Forms / frmDemoM.frm next >
Text File  |  2005-12-09  |  19KB  |  629 lines

  1. VERSION 5.00
  2. Object = "*\A..\Calendar.vbp"
  3. Begin VB.Form frmDemoM 
  4.    Caption         =   "Calendar Markings Demo"
  5.    ClientHeight    =   4692
  6.    ClientLeft      =   132
  7.    ClientTop       =   -180
  8.    ClientWidth     =   9972
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   4692
  11.    ScaleWidth      =   9972
  12.    StartUpPosition =   2  'CenterScreen
  13.    Begin CalendarOcx.Calendar calDemo 
  14.       Height          =   4068
  15.       Left            =   120
  16.       TabIndex        =   24
  17.       Top             =   480
  18.       Width           =   4572
  19.       _ExtentX        =   8065
  20.       _ExtentY        =   7176
  21.       ArrowColor      =   12582912
  22.       BackColor       =   14737632
  23.       ButtonColor     =   12632256
  24.       ButtonGradientColor=   16777215
  25.       ButtonGradientStyle=   4
  26.       CellDayOfYearForeColor=   12583104
  27.       CellDayOfYearStyle=   0
  28.       CellForeColorSunday=   255
  29.       CellForeColorMonday=   8388736
  30.       CellForeColorTuesday=   8388736
  31.       CellForeColorWednesday=   8388736
  32.       CellForeColorThursday=   8388736
  33.       CellForeColorFriday=   8388736
  34.       CellForeColorSaturday=   12582912
  35.       CellHeaderStyle =   0
  36.       CellOtherMonthForeColor=   8421504
  37.       CellOtherMonthView=   -1  'True
  38.       CellSelectForeColor=   12582912
  39.       CellSelectHeaderForeColor=   12632256
  40.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  41.          Name            =   "Arial"
  42.          Size            =   7.8
  43.          Charset         =   0
  44.          Weight          =   700
  45.          Underline       =   0   'False
  46.          Italic          =   0   'False
  47.          Strikethrough   =   0   'False
  48.       EndProperty
  49.       FrameStyle      =   1
  50.       FrameColor      =   8421504
  51.       GradientColor   =   16777215
  52.       GradientStyle   =   4
  53.       GridColor       =   12632256
  54.       GridStyle       =   2
  55.       LabelBackStyle  =   0
  56.       LabelBorderStyle=   0
  57.       LabelFontBold   =   -1  'True
  58.       LabelForeColor  =   8388736
  59.       ShowInfoBar     =   1
  60.       ShowNavigationBar=   1
  61.       WeekDayViewChar =   2
  62.       WeekNumberForeColor=   12582912
  63.    End
  64.    Begin VB.Frame fraSettings 
  65.       Caption         =   "Some Settings"
  66.       BeginProperty Font 
  67.          Name            =   "MS Sans Serif"
  68.          Size            =   7.8
  69.          Charset         =   0
  70.          Weight          =   700
  71.          Underline       =   0   'False
  72.          Italic          =   0   'False
  73.          Strikethrough   =   0   'False
  74.       EndProperty
  75.       ForeColor       =   &H00800080&
  76.       Height          =   4572
  77.       Left            =   4920
  78.       TabIndex        =   3
  79.       Top             =   0
  80.       Width           =   4932
  81.       Begin VB.CheckBox chkOptions 
  82.          Alignment       =   1  'Right Justify
  83.          Caption         =   "ShowToolTipText:"
  84.          ForeColor       =   &H00C00000&
  85.          Height          =   252
  86.          Index           =   3
  87.          Left            =   120
  88.          TabIndex        =   23
  89.          Top             =   4200
  90.          Width           =   4692
  91.       End
  92.       Begin VB.ComboBox cmbGrid 
  93.          ForeColor       =   &H00800080&
  94.          Height          =   288
  95.          ItemData        =   "frmDemoM.frx":0000
  96.          Left            =   120
  97.          List            =   "frmDemoM.frx":0013
  98.          Style           =   2  'Dropdown List
  99.          TabIndex        =   14
  100.          Top             =   2280
  101.          Width           =   2292
  102.       End
  103.       Begin VB.CheckBox chkOptions 
  104.          Alignment       =   1  'Right Justify
  105.          Caption         =   "ShowNavigationBar:"
  106.          ForeColor       =   &H00C00000&
  107.          Height          =   252
  108.          Index           =   0
  109.          Left            =   120
  110.          TabIndex        =   13
  111.          Top             =   3120
  112.          Width           =   4692
  113.       End
  114.       Begin VB.CheckBox chkOptions 
  115.          Alignment       =   1  'Right Justify
  116.          Caption         =   "ShowInfoBar:"
  117.          ForeColor       =   &H00C00000&
  118.          Height          =   252
  119.          Index           =   1
  120.          Left            =   120
  121.          TabIndex        =   12
  122.          Top             =   3480
  123.          Width           =   4692
  124.       End
  125.       Begin VB.CheckBox chkOptions 
  126.          Alignment       =   1  'Right Justify
  127.          Caption         =   "ShowOtherMonths:"
  128.          ForeColor       =   &H00C00000&
  129.          Height          =   252
  130.          Index           =   2
  131.          Left            =   120
  132.          TabIndex        =   11
  133.          Top             =   3840
  134.          Width           =   4692
  135.       End
  136.       Begin VB.ComboBox cmbGradient 
  137.          ForeColor       =   &H00800080&
  138.          Height          =   288
  139.          ItemData        =   "frmDemoM.frx":004A
  140.          Left            =   120
  141.          List            =   "frmDemoM.frx":005D
  142.          Style           =   2  'Dropdown List
  143.          TabIndex        =   10
  144.          Top             =   1080
  145.          Width           =   2292
  146.       End
  147.       Begin VB.ComboBox cmbButtonGradient 
  148.          ForeColor       =   &H00800080&
  149.          Height          =   288
  150.          ItemData        =   "frmDemoM.frx":009D
  151.          Left            =   120
  152.          List            =   "frmDemoM.frx":00B0
  153.          Style           =   2  'Dropdown List
  154.          TabIndex        =   9
  155.          Top             =   480
  156.          Width           =   2292
  157.       End
  158.       Begin VB.ComboBox cmbLanguage 
  159.          ForeColor       =   &H00800080&
  160.          Height          =   288
  161.          ItemData        =   "frmDemoM.frx":00F0
  162.          Left            =   2520
  163.          List            =   "frmDemoM.frx":0106
  164.          Style           =   2  'Dropdown List
  165.          TabIndex        =   8
  166.          Top             =   480
  167.          Width           =   2292
  168.       End
  169.       Begin VB.ComboBox cmbFrame 
  170.          ForeColor       =   &H00800080&
  171.          Height          =   288
  172.          ItemData        =   "frmDemoM.frx":013C
  173.          Left            =   120
  174.          List            =   "frmDemoM.frx":0149
  175.          Style           =   2  'Dropdown List
  176.          TabIndex        =   7
  177.          Top             =   1680
  178.          Width           =   2292
  179.       End
  180.       Begin VB.ComboBox cmbWeekDay 
  181.          ForeColor       =   &H00800080&
  182.          Height          =   288
  183.          ItemData        =   "frmDemoM.frx":0160
  184.          Left            =   2520
  185.          List            =   "frmDemoM.frx":0162
  186.          Style           =   2  'Dropdown List
  187.          TabIndex        =   6
  188.          Top             =   1080
  189.          Width           =   2292
  190.       End
  191.       Begin VB.ComboBox cmbDateFormat 
  192.          ForeColor       =   &H00800080&
  193.          Height          =   288
  194.          ItemData        =   "frmDemoM.frx":0164
  195.          Left            =   2520
  196.          List            =   "frmDemoM.frx":0171
  197.          Style           =   2  'Dropdown List
  198.          TabIndex        =   5
  199.          Top             =   1680
  200.          Width           =   2292
  201.       End
  202.       Begin VB.ComboBox cmbHemisphere 
  203.          ForeColor       =   &H00800080&
  204.          Height          =   288
  205.          ItemData        =   "frmDemoM.frx":0199
  206.          Left            =   2520
  207.          List            =   "frmDemoM.frx":01A3
  208.          Style           =   2  'Dropdown List
  209.          TabIndex        =   4
  210.          Top             =   2280
  211.          Width           =   2292
  212.       End
  213.       Begin VB.Label lblSetting 
  214.          AutoSize        =   -1  'True
  215.          Caption         =   "GridStyle:"
  216.          ForeColor       =   &H00C00000&
  217.          Height          =   192
  218.          Index           =   2
  219.          Left            =   120
  220.          TabIndex        =   22
  221.          Top             =   2040
  222.          Width           =   696
  223.       End
  224.       Begin VB.Label lblSetting 
  225.          AutoSize        =   -1  'True
  226.          Caption         =   "GradientType:"
  227.          ForeColor       =   &H00C00000&
  228.          Height          =   192
  229.          Index           =   1
  230.          Left            =   120
  231.          TabIndex        =   21
  232.          Top             =   840
  233.          Width           =   1032
  234.       End
  235.       Begin VB.Label lblSetting 
  236.          AutoSize        =   -1  'True
  237.          Caption         =   "ButtonGradientType:"
  238.          ForeColor       =   &H00C00000&
  239.          Height          =   192
  240.          Index           =   0
  241.          Left            =   120
  242.          TabIndex        =   20
  243.          Top             =   240
  244.          Width           =   1476
  245.       End
  246.       Begin VB.Label lblSetting 
  247.          AutoSize        =   -1  'True
  248.          Caption         =   "Language:"
  249.          ForeColor       =   &H00C00000&
  250.          Height          =   312
  251.          Index           =   3
  252.          Left            =   2520
  253.          TabIndex        =   19
  254.          Top             =   240
  255.          Width           =   768
  256.       End
  257.       Begin VB.Label lblSetting 
  258.          AutoSize        =   -1  'True
  259.          Caption         =   "FrameStyle:"
  260.          ForeColor       =   &H00C00000&
  261.          Height          =   192
  262.          Index           =   4
  263.          Left            =   120
  264.          TabIndex        =   18
  265.          Top             =   1440
  266.          Width           =   864
  267.       End
  268.       Begin VB.Label lblSetting 
  269.          AutoSize        =   -1  'True
  270.          Caption         =   "FirstWeekDay:"
  271.          ForeColor       =   &H00C00000&
  272.          Height          =   192
  273.          Index           =   5
  274.          Left            =   2520
  275.          TabIndex        =   17
  276.          Top             =   840
  277.          Width           =   1068
  278.       End
  279.       Begin VB.Label lblSetting 
  280.          AutoSize        =   -1  'True
  281.          Caption         =   "DateFormat:"
  282.          ForeColor       =   &H00C00000&
  283.          Height          =   192
  284.          Index           =   6
  285.          Left            =   2520
  286.          TabIndex        =   16
  287.          Top             =   1440
  288.          Width           =   888
  289.       End
  290.       Begin VB.Label lblSetting 
  291.          AutoSize        =   -1  'True
  292.          Caption         =   "Hemisphere:"
  293.          ForeColor       =   &H00C00000&
  294.          Height          =   192
  295.          Index           =   7
  296.          Left            =   2520
  297.          TabIndex        =   15
  298.          Top             =   2040
  299.          Width           =   924
  300.       End
  301.       Begin VB.Image imgLine 
  302.          BorderStyle     =   1  'Fixed Single
  303.          Height          =   12
  304.          Left            =   120
  305.          Top             =   2880
  306.          Width           =   4692
  307.       End
  308.    End
  309.    Begin VB.ComboBox cmbMonth 
  310.       ForeColor       =   &H00800080&
  311.       Height          =   288
  312.       Left            =   1320
  313.       Style           =   2  'Dropdown List
  314.       TabIndex        =   2
  315.       Top             =   45
  316.       Width           =   1092
  317.    End
  318.    Begin VB.ComboBox cmbYear 
  319.       ForeColor       =   &H00800080&
  320.       Height          =   288
  321.       Left            =   90
  322.       Style           =   2  'Dropdown List
  323.       TabIndex        =   1
  324.       Top             =   45
  325.       Width           =   960
  326.    End
  327.    Begin VB.Image imgBorder 
  328.       BorderStyle     =   1  'Fixed Single
  329.       Height          =   4116
  330.       Left            =   96
  331.       Top             =   456
  332.       Width           =   4620
  333.    End
  334.    Begin VB.Label lblDate 
  335.       Alignment       =   1  'Right Justify
  336.       AutoSize        =   -1  'True
  337.       Caption         =   "lblDate"
  338.       BeginProperty Font 
  339.          Name            =   "MS Sans Serif"
  340.          Size            =   9.6
  341.          Charset         =   0
  342.          Weight          =   700
  343.          Underline       =   0   'False
  344.          Italic          =   0   'False
  345.          Strikethrough   =   0   'False
  346.       EndProperty
  347.       ForeColor       =   &H00FF0000&
  348.       Height          =   240
  349.       Left            =   3960
  350.       TabIndex        =   0
  351.       Top             =   120
  352.       Width           =   732
  353.    End
  354.    Begin VB.Menu mnuMarkings 
  355.       Caption         =   "Markings"
  356.       Visible         =   0   'False
  357.       Begin VB.Menu mnuMark 
  358.          Caption         =   "Mark"
  359.          Begin VB.Menu mnuMarkType 
  360.             Caption         =   "Type 1"
  361.             Index           =   0
  362.          End
  363.          Begin VB.Menu mnuMarkType 
  364.             Caption         =   "Type 2"
  365.             Index           =   1
  366.          End
  367.          Begin VB.Menu mnuMarkType 
  368.             Caption         =   "Type 3"
  369.             Index           =   2
  370.          End
  371.          Begin VB.Menu mnuMarkType 
  372.             Caption         =   "Type 4"
  373.             Index           =   3
  374.          End
  375.          Begin VB.Menu mnuMarkType 
  376.             Caption         =   "Type 5"
  377.             Index           =   4
  378.          End
  379.       End
  380.       Begin VB.Menu mnuDemark 
  381.          Caption         =   "Demark"
  382.          Begin VB.Menu mnuDemarkType 
  383.             Caption         =   "Type 1"
  384.             Index           =   0
  385.          End
  386.          Begin VB.Menu mnuDemarkType 
  387.             Caption         =   "Type 2"
  388.             Index           =   1
  389.          End
  390.          Begin VB.Menu mnuDemarkType 
  391.             Caption         =   "Type 3"
  392.             Index           =   2
  393.          End
  394.          Begin VB.Menu mnuDemarkType 
  395.             Caption         =   "Type 4"
  396.             Index           =   3
  397.          End
  398.          Begin VB.Menu mnuDemarkType 
  399.             Caption         =   "Type 5"
  400.             Index           =   4
  401.          End
  402.       End
  403.    End
  404. End
  405. Attribute VB_Name = "frmDemoM"
  406. Attribute VB_GlobalNameSpace = False
  407. Attribute VB_Creatable = False
  408. Attribute VB_PredeclaredId = True
  409. Attribute VB_Exposed = False
  410. 'Demo program for Calendar Control
  411. '
  412. 'Author Ben Vonk
  413. '20-08-2004 First version
  414. '29-10-2005 Second version (based on Stefaan Casier's 'Owner Drawn Calendar Control' at http://www.codeguru.com/vb/controls/vb_othctrl/ocxcontrols/article.php/c1521/)
  415.  
  416. ' This example demonstrates how Calendar control can be used.
  417. ' It shows how to (de)mark only selected calendar days, using a popup menu.
  418. ' The marking-changes you make in this demo are not stored.
  419.  
  420. Option Explicit
  421.                         ' in case you want to detect changes elsewhere
  422. Dim Changes As Boolean  ' not really used in this program
  423.  
  424. Private Sub DoMarkers(ByVal Index As Integer, ByVal Status As Boolean)
  425.  
  426. Dim intDay As Integer
  427.  
  428.    With calDemo
  429.       For intDay = 1 To .GetMonthDays
  430.          ' day, type, on/off
  431.          ' here comes code that changes your data
  432.          If .IsDaySel(intDay) Then Call .DayMarking(intDay, Index, Status)
  433.       Next 'intDay
  434.       
  435.       .Refresh
  436.       Changes = True
  437.    End With
  438.  
  439. End Sub
  440.  
  441. Private Sub FillDate()
  442.  
  443.    With calDemo
  444.       lblDate.Caption = Format(DateSerial(.CalYear, .CalMonth, .CalDay), cmbDateFormat.Text)
  445.    End With
  446.  
  447. End Sub
  448.  
  449. Private Sub calDemo_DayClick(Button As Integer, Shift As Integer, IsDay As Integer, IsMonth As Integer, Cancel As Boolean)
  450.  
  451.    If Button = vbRightButton Then
  452.       PopupMenu mnuMarkings
  453.       Cancel = True  ' cancel normal action: (de-)selection of cell
  454.    End If
  455.  
  456. End Sub
  457.  
  458. Private Sub chkOptions_Click(Index As Integer)
  459.  
  460.    With calDemo
  461.       Select Case Index
  462.          Case 0
  463.             .ShowNavigationBar = IIf(chkOptions.Item(Index).Value, Small, Off)
  464.             
  465.          Case 1
  466.             .ShowInfoBar = IIf(chkOptions.Item(Index).Value, Small, Off)
  467.             
  468.          Case 2
  469.             .CellOtherMonthView = CBool(chkOptions.Item(Index).Value)
  470.             
  471.          Case 3
  472.             .ShowToolTipText = CBool(chkOptions.Item(Index).Value)
  473.       End Select
  474.    End With
  475.  
  476. End Sub
  477.  
  478. Private Sub cmbButtonGradient_Click()
  479.  
  480.    calDemo.ButtonGradientStyle = cmbButtonGradient.ListIndex
  481.  
  482. End Sub
  483.  
  484. Private Sub cmbDateFormat_Click()
  485.  
  486.    calDemo.DateFormat = cmbDateFormat.ListIndex
  487.    
  488.    Call FillDate
  489.  
  490. End Sub
  491.  
  492. Private Sub cmbFrame_Click()
  493.  
  494.    calDemo.FrameStyle = cmbFrame.ListIndex
  495.  
  496. End Sub
  497.  
  498. Private Sub cmbGradient_Click()
  499.  
  500.    calDemo.GradientStyle = cmbGradient.ListIndex
  501.  
  502. End Sub
  503.  
  504. Private Sub cmbGrid_Click()
  505.  
  506.    calDemo.GridStyle = cmbGrid.ListIndex
  507.  
  508. End Sub
  509.  
  510. Private Sub cmbHemisphere_Click()
  511.  
  512.    calDemo.Hemisphere = cmbHemisphere.ListIndex
  513.    
  514. End Sub
  515.  
  516. Private Sub cmbLanguage_Click()
  517.  
  518.    calDemo.Language = cmbLanguage.ListIndex
  519.  
  520. End Sub
  521.  
  522. Private Sub cmbMonth_Click()
  523.  
  524.    calDemo.CalMonth = cmbMonth.ListIndex + 1
  525.    
  526.    Call FillDate
  527.  
  528. End Sub
  529.  
  530. Private Sub cmbWeekDay_Click()
  531.  
  532.    calDemo.FirstWeekDay = cmbWeekDay.ListIndex
  533.  
  534. End Sub
  535.  
  536. Private Sub cmbYear_Click()
  537.  
  538.    calDemo.CalYear = cmbYear.List(cmbYear.ListIndex)
  539.    
  540.    Call FillDate
  541.  
  542. End Sub
  543.  
  544. Private Sub Form_Load()
  545.  
  546. Dim intCount As Integer
  547.  
  548.    frmDemoS.Show
  549.    DoEvents
  550.    Height = 5472
  551.    intCount = Val(Format(Now, "yyyy"))
  552.     
  553.    For intCount = intCount - 6 To intCount + 6
  554.       cmbYear.AddItem Str(intCount)
  555.    Next 'intCount
  556.    
  557.    With calDemo
  558.       .Locked = True
  559.       cmbYear.ListIndex = 6
  560.       
  561.       For intCount = 1 To 12
  562.          cmbMonth.AddItem calDemo.GetMonthName(intCount)
  563.       Next 'intCount
  564.       
  565.       cmbMonth.ListIndex = Month(Now) - 1
  566.       
  567.       For intCount = 1 To 7
  568.          cmbWeekDay.AddItem .GetWeekDayName(intCount)
  569.       Next 'intCount
  570.       
  571.       cmbWeekDay.ListIndex = .FirstWeekDay
  572.       cmbButtonGradient.ListIndex = .ButtonGradientStyle
  573.       cmbGradient.ListIndex = .GradientStyle
  574.       cmbFrame.ListIndex = .FrameStyle
  575.       cmbGrid.ListIndex = .GridStyle
  576.       cmbLanguage.ListIndex = .Language
  577.       cmbDateFormat.ListIndex = .DateFormat
  578.       cmbHemisphere.ListIndex = .Hemisphere
  579.       chkOptions.Item(0).Value = .ShowNavigationBar
  580.       chkOptions.Item(1).Value = .ShowInfoBar
  581.       chkOptions.Item(2).Value = Abs(.CellOtherMonthView)
  582.       chkOptions.Item(3).Value = Abs(.ShowToolTipText)
  583.       .Locked = False
  584.    End With
  585.    
  586.    Call FillDate
  587.  
  588. End Sub
  589.  
  590. Private Sub Form_Resize()
  591.  
  592.    If WindowState = 1 Then Exit Sub
  593.    
  594.    If WindowState = 0 Then
  595.       If Width < 10068 Then Width = 10068
  596.       If Height < 5472 Then Height = 5472
  597.    End If
  598.    
  599.    With calDemo
  600.       fraSettings.Left = ScaleWidth - fraSettings.Width - 120
  601.       .Width = fraSettings.Left - 300
  602.       .Height = ScaleHeight - calDemo.Top - 120
  603.       imgBorder.Left = .Left - Screen.TwipsPerPixelX * 2
  604.       imgBorder.Top = .Top - Screen.TwipsPerPixelY * 2
  605.       imgBorder.Width = .Width + Screen.TwipsPerPixelX * 4
  606.       imgBorder.Height = .Height + Screen.TwipsPerPixelY * 4
  607.    End With
  608.  
  609. End Sub
  610.  
  611. Private Sub mnuDemarkType_Click(Index As Integer)
  612.  
  613.    Call DoMarkers(Index + 1, False)
  614.  
  615. End Sub
  616.  
  617. Private Sub mnuMarkType_Click(Index As Integer)
  618.  
  619.    Call DoMarkers(Index + 1, True)
  620.  
  621. End Sub
  622.  
  623. Private Sub calDemo_SelChanged()
  624.  
  625.    Call FillDate
  626.  
  627. End Sub
  628.  
  629.