home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / componen / vsflex / demo / fcal.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-08-30  |  6.2 KB  |  196 lines

  1. VERSION 2.00
  2. Begin Form fCalendar 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "FlexCalendar"
  6.    ClientHeight    =   3870
  7.    ClientLeft      =   1095
  8.    ClientTop       =   1485
  9.    ClientWidth     =   7245
  10.    Height          =   4275
  11.    Icon            =   0
  12.    Left            =   1035
  13.    LinkTopic       =   "Form1"
  14.    ScaleHeight     =   3870
  15.    ScaleWidth      =   7245
  16.    Top             =   1140
  17.    Width           =   7365
  18.    Begin TextBox txtNotes 
  19.       BackColor       =   &H00FFFFFF&
  20.       FontBold        =   0   'False
  21.       FontItalic      =   0   'False
  22.       FontName        =   "MS Sans Serif"
  23.       FontSize        =   8.25
  24.       FontStrikethru  =   0   'False
  25.       FontUnderline   =   0   'False
  26.       ForeColor       =   &H00000000&
  27.       Height          =   1095
  28.       Left            =   5175
  29.       TabIndex        =   3
  30.       Text            =   "Notes:"
  31.       Top             =   2520
  32.       Visible         =   0   'False
  33.       Width           =   2010
  34.    End
  35.    Begin vsFlexArray cal 
  36.       BackColor       =   &H00C0C0C0&
  37.       BackColorSel    =   &H00000080&
  38.       Cols            =   7
  39.       FixedCols       =   0
  40.       FontBold        =   0   'False
  41.       FontItalic      =   0   'False
  42.       FontName        =   "MS Sans Serif"
  43.       FontSize        =   8.25
  44.       FontStrikethru  =   0   'False
  45.       FontUnderline   =   0   'False
  46.       ForeColor       =   &H00000000&
  47.       GridLines       =   2  'Inset
  48.       Height          =   2880
  49.       Left            =   240
  50.       RowHeightMin    =   405
  51.       Rows            =   7
  52.       ScrollBars      =   0  'None
  53.       TabIndex        =   1
  54.       Top             =   780
  55.       Width           =   6765
  56.    End
  57.    Begin Label Label2 
  58.       AutoSize        =   -1  'True
  59.       BackStyle       =   0  'Transparent
  60.       Caption         =   "Drag and Drop -->"
  61.       FontBold        =   0   'False
  62.       FontItalic      =   0   'False
  63.       FontName        =   "MS Sans Serif"
  64.       FontSize        =   8.25
  65.       FontStrikethru  =   0   'False
  66.       FontUnderline   =   0   'False
  67.       ForeColor       =   &H00800080&
  68.       Height          =   195
  69.       Left            =   3930
  70.       TabIndex        =   2
  71.       Top             =   360
  72.       Width           =   1275
  73.    End
  74.    Begin Image Image1 
  75.       Height          =   330
  76.       Index           =   3
  77.       Left            =   6060
  78.       Picture         =   FCAL.FRX:0000
  79.       Top             =   315
  80.       Width           =   360
  81.    End
  82.    Begin Image Image1 
  83.       Height          =   330
  84.       Index           =   2
  85.       Left            =   5655
  86.       Picture         =   FCAL.FRX:0182
  87.       Top             =   315
  88.       Width           =   360
  89.    End
  90.    Begin Image Image1 
  91.       Height          =   330
  92.       Index           =   1
  93.       Left            =   5250
  94.       Picture         =   FCAL.FRX:0304
  95.       Top             =   315
  96.       Width           =   360
  97.    End
  98.    Begin Image Image1 
  99.       Height          =   330
  100.       Index           =   0
  101.       Left            =   4755
  102.       Top             =   330
  103.       Visible         =   0   'False
  104.       Width           =   390
  105.    End
  106.    Begin Label Label1 
  107.       Alignment       =   2  'Center
  108.       BackColor       =   &H00000000&
  109.       Caption         =   "Label1"
  110.       FontBold        =   -1  'True
  111.       FontItalic      =   0   'False
  112.       FontName        =   "Arial"
  113.       FontSize        =   18
  114.       FontStrikethru  =   0   'False
  115.       FontUnderline   =   0   'False
  116.       ForeColor       =   &H0000FFFF&
  117.       Height          =   465
  118.       Left            =   240
  119.       TabIndex        =   0
  120.       Top             =   270
  121.       Width           =   3420
  122.    End
  123. Option Explicit
  124. Dim TempDate#
  125. Sub cal_DblClick ()
  126.    ' avoid first row or blank days
  127.    If cal.MouseRow = 0 Or cal = "" Then Exit Sub
  128.    txtNotes.Move (cal.CellLeft + cal.Left) + 100, (cal.CellTop + cal.Top) + 100
  129.    txtNotes.Visible = True
  130.    txtNotes.SetFocus
  131. End Sub
  132. Sub cal_DragDrop (Source As Control, X As Single, Y As Single)
  133.    ' avoid first row and blank days
  134.    If cal.MouseRow = 0 Or cal = "" Then Exit Sub
  135.    ' drop picture to cell
  136.    cal.Row = cal.MouseRow
  137.    cal.Col = cal.MouseCol
  138.    cal.CellPicture = Source
  139.    cal.CellPictureAlignment = 1
  140.    cal.CellBackColor = &H80FFFF
  141. End Sub
  142. Sub DoCalendar (AnyDate)
  143.    Dim FirstOfMonth#, FirstOfNextMonth#, DateOffset#, NumDays#
  144.    Dim i%, j%, k%, FiveWeeks%, NumOf%
  145.    ' Basic Date Math to calculate view --------------------------
  146.    TempDate = AnyDate                     ' save date for future reference
  147.    FirstOfMonth = DateSerial(Year(AnyDate), Month(AnyDate), 1)
  148.    FirstOfNextMonth = DateSerial(Year(AnyDate), Month(AnyDate) + 1, 1)
  149.    NumDays = FirstOfNextMonth - FirstOfMonth
  150.    DateOffset = Weekday(FirstOfMonth) - 1
  151.    ' ------------------------------------------------------------
  152.    cal.Clear            'Clear off the grid
  153.    cal.Row = 0
  154.    cal.FormatString = "^SUN|^MON|^TUE|^WED|^THU|^FRI|^SAT"
  155.    cal.Row = 1
  156.    ' place datenumbers into the cells
  157.    k = DateOffset - 1
  158.    For i = 1 To NumDays
  159.        k = k + 1
  160.        If k = 7 Then
  161.            k = 0
  162.            cal.Row = cal.Row + 1
  163.        End If
  164.        
  165.        ' check to see if the month uses 5 or 6 weeks to display
  166.        FiveWeeks = True
  167.        If cal.Row = 6 Then FiveWeeks = False
  168.        
  169.        cal.Col = k
  170.        cal = Str$(i)
  171.        cal.CellAlignment = 6
  172.        cal.CellPictureAlignment = 4
  173.    Next
  174.    label1 = Format$(FirstOfMonth, "MMMM YYYY")
  175.    ' resize the grid cells to fit form
  176.    For i = 0 To 6
  177.        cal.ColWidth(i) = (cal.Width / 7)
  178.        NumOf% = 5
  179.        If FiveWeeks = True Then NumOf = 6
  180.        For j = 1 To 6
  181.            cal.RowHeight(j) = (cal.Height / NumOf) - ((cal.RowHeight(0) / NumOf))
  182.        Next
  183.    Next
  184.    cal.TopRow = 0
  185. End Sub
  186. Sub Form_Load ()
  187.    DoCalendar Now
  188. End Sub
  189. Sub Image1_MouseDown (Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
  190.    txtNotes.Visible = False
  191.    Image1(Index).Drag 1
  192. End Sub
  193. Sub txtNotes_LostFocus ()
  194.    txtNotes.Visible = False
  195. End Sub
  196.