home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / tool / various / kalend / test2.frm < prev    next >
Text File  |  1995-02-27  |  6KB  |  172 lines

  1. VERSION 2.00
  2. Begin Form Form2 
  3.    BorderStyle     =   3  'Fixed Double
  4.    Caption         =   "Complete Custom Day"
  5.    ClientHeight    =   3675
  6.    ClientLeft      =   3195
  7.    ClientTop       =   345
  8.    ClientWidth     =   4845
  9.    Height          =   4200
  10.    Left            =   3135
  11.    LinkTopic       =   "Form2"
  12.    ScaleHeight     =   3675
  13.    ScaleWidth      =   4845
  14.    Top             =   -120
  15.    Width           =   4965
  16.    Begin ComboBox lstMonth 
  17.       Height          =   300
  18.       Left            =   105
  19.       Style           =   2  'Dropdown List
  20.       TabIndex        =   2
  21.       Top             =   105
  22.       Width           =   3060
  23.    End
  24.    Begin ComboBox lstYear 
  25.       Height          =   300
  26.       Left            =   3255
  27.       Style           =   2  'Dropdown List
  28.       TabIndex        =   1
  29.       Top             =   105
  30.       Width           =   1485
  31.    End
  32.    Begin Kalendar Kalendar1 
  33.       BackColor       =   &H00FFFFFF&
  34.       BorderStyle     =   1  'Fixed Single
  35.       DateDispStyle   =   2  'User
  36.       DayAlignment    =   0  'Upper Left
  37.       DOWAlign        =   2  'Center
  38.       DOWBackColor    =   &H0000FFFF&
  39.       DOWBorder       =   0   'False
  40.       DOWDispStyle    =   2  'Medium
  41.       DOWFontBold     =   -1  'True
  42.       DOWFontItalic   =   0   'False
  43.       DOWFontName     =   "MS Sans Serif"
  44.       DOWFontSize     =   8.25
  45.       DOWFontStrikeThru=   0   'False
  46.       DOWFontUnderline=   0   'False
  47.       DOWForeColor    =   &H00000000&
  48.       EnableKeys      =   -1  'True
  49.       FirstDOW        =   0  'Sunday
  50.       FixedDayHeight  =   0   'False
  51.       ForeColor       =   &H00000000&
  52.       Height          =   3195
  53.       Left            =   105
  54.       LineColor       =   &H00C0C0C0&
  55.       MonAlign        =   2  'Center
  56.       MonBackColor    =   &H0000FFFF&
  57.       MonDispStyle    =   0  'None
  58.       MonFontBold     =   -1  'True
  59.       MonFontItalic   =   0   'False
  60.       MonFontName     =   "MS Sans Serif"
  61.       MonFontSize     =   8.25
  62.       MonFontStrikeThru=   0   'False
  63.       MonFontUnderline=   0   'False
  64.       MonForeColor    =   &H00000000&
  65.       OtherMonBackColor=   &H00C0C0C0&
  66.       OtherMonForeColor=   &H00FFFFFF&
  67.       SelDayBackColor =   &H000000FF&
  68.       SelDayForeColor =   &H00000000&
  69.       ShowAllDays     =   0   'False
  70.       ShowArrows      =   -1  'True
  71.       ShowLines       =   -1  'True
  72.       ShowSelection   =   -1  'True
  73.       TabIndex        =   0
  74.       Text            =   "01/04/94"
  75.       Top             =   390
  76.       Width           =   4635
  77.    End
  78. End
  79. Option Explicit
  80.  
  81. Sub Form_Activate ()
  82.     SetDescription Sample2Description()
  83. End Sub
  84.  
  85. Sub Form_Load ()
  86. Dim i As Integer
  87.     lstMonth.AddItem "January"
  88.     lstMonth.AddItem "February"
  89.     lstMonth.AddItem "March"
  90.     lstMonth.AddItem "April"
  91.     lstMonth.AddItem "May"
  92.     lstMonth.AddItem "June"
  93.     lstMonth.AddItem "July"
  94.     lstMonth.AddItem "August"
  95.     lstMonth.AddItem "September"
  96.     lstMonth.AddItem "October"
  97.     lstMonth.AddItem "November"
  98.     lstMonth.AddItem "December"
  99.  
  100.     For i = 1962 To 2020
  101.         lstYear.AddItem "" & i
  102.     Next
  103.  
  104.     Kalendar1.Text = Date
  105. End Sub
  106.  
  107. Sub Kalendar1_ClickDay ()
  108.     UpdateCombos Kalendar1, lstMonth, lstYear
  109. End Sub
  110.  
  111. Sub Kalendar1_DrawDay (hDC As Integer, State As Integer, theDay As Long, x As Single, y As Single, x2 As Single, y2 As Single, Cancel As Integer)
  112. Dim retval As Integer
  113. Dim oldPen As Integer
  114. Dim txtDay As String
  115. Dim r As Rect
  116. Dim oldBrush
  117. Dim oldColor, oldTextColor
  118. Dim lx As Long
  119.  
  120.     txtDay = Format(theDay, "d")
  121.  
  122.     ' Convert the rectangle back to twips for the form.
  123.     r.left = x / Screen.TwipsPerPixelX
  124.     r.top = y / Screen.TwipsPerPixelY
  125.     r.right = x2 / Screen.TwipsPerPixelX
  126.     r.bottom = y2 / Screen.TwipsPerPixelY
  127.  
  128.     oldPen = SelectObject(hDC, GetStockObject(BLACK_PEN))
  129.  
  130.     Select Case State
  131.         Case KAL_STATE_SELECTED_WITHOUT:
  132.             oldBrush = SelectObject(hDC, GetStockObject(LTGRAY_BRUSH))
  133.             oldColor = SetBkColor(hDC, RGB(192, 192, 192))
  134.             oldTextColor = SetTextColor(hDC, 0)
  135.         Case KAL_STATE_SELECTED_WITH:
  136.             oldBrush = SelectObject(hDC, GetStockObject(LTGRAY_BRUSH))
  137.             oldColor = SetBkColor(hDC, RGB(192, 192, 192))
  138.             oldTextColor = SetTextColor(hDC, RGB(255, 0, 0))
  139.         Case KAL_STATE_NOT_SELECTED:
  140.             oldBrush = SelectObject(hDC, GetStockObject(WHITE_BRUSH))
  141.             oldColor = SetBkColor(hDC, RGB(255, 255, 255))
  142.             oldColor = SetTextColor(hDC, 0)
  143.     End Select
  144.     retval = Ellipse(hDC, r.left, r.top, r.right, r.bottom)
  145.     retval = DrawText(hDC, txtDay, Len(txtDay), r, DT_CENTER Or DT_VCENTER Or DT_SINGLELINE)
  146.  
  147.     retval = SelectObject(hDC, oldPen)
  148.     retval = SelectObject(hDC, oldBrush)
  149.     lx = SetBkColor(hDC, oldColor)
  150.     lx = SetTextColor(hDC, oldTextColor)
  151.     Cancel = True
  152. End Sub
  153.  
  154. Sub lstMonth_Click ()
  155.     KalSetMonth Kalendar1, lstMonth.ListIndex + 1, 1, Val(lstYear.Text)
  156. End Sub
  157.  
  158. Sub lstYear_Click ()
  159.     KalSetMonth Kalendar1, lstMonth.ListIndex + 1, 1, Val(lstYear.Text)
  160. End Sub
  161.  
  162. Function Sample2Description () As String
  163. Dim S As String
  164. Dim CR As String
  165.  
  166.     S = "This sample shows how the programmer has complete control over how the day boxes are drawn in a Kalendar. Each day "
  167.     S = S & "box is drawn by using the Windows API function Ellipse." & CR
  168.     S = S & "This sample also shows a custom 'month navigation' method."
  169.     Sample2Description = S
  170. End Function
  171.  
  172.