home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Unleashed / Visual_Basic_4_Unleashed_SAMS_Publishing_1995.iso / truegrid / disk1 / apptbook / apptbook.$ / APPTBOOK.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-02-17  |  28.2 KB  |  778 lines

  1. VERSION 2.00
  2. Begin Form ApptForm 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Appointments"
  5.    ClientHeight    =   5055
  6.    ClientLeft      =   840
  7.    ClientTop       =   1740
  8.    ClientWidth     =   7320
  9.    Height          =   5745
  10.    Icon            =   APPTBOOK.FRX:0000
  11.    Left            =   780
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   5055
  14.    ScaleWidth      =   7320
  15.    Top             =   1110
  16.    Width           =   7440
  17.    Begin TrueGrid ApptList 
  18.       AllowArrows     =   -1  'True
  19.       AllowTabs       =   -1  'True
  20.       Editable        =   0   'False
  21.       EditDropDown    =   -1  'True
  22.       ExposeCellMode  =   0  'Expose upon selection
  23.       FetchMode       =   0  'By cell
  24.       HeadingHeight   =   1
  25.       Height          =   2835
  26.       HorzLines       =   1  'Single
  27.       Layout          =   APPTBOOK.FRX:0302
  28.       Left            =   120
  29.       LinesPerRow     =   1
  30.       MarqueeUnique   =   -1  'True
  31.       SplitPropsGlobal=   -1  'True
  32.       SplitTabMode    =   0  'Don't tab across splits
  33.       TabCapture      =   0   'False
  34.       TabIndex        =   16
  35.       Top             =   240
  36.       UseBookmarks    =   -1  'True
  37.       Width           =   4275
  38.       WrapCellPointer =   0   'False
  39.    End
  40.    Begin SSPanel Panel3D2 
  41.       Alignment       =   6  'Center - TOP
  42.       BevelOuter      =   1  'Inset
  43.       BorderWidth     =   2
  44.       Caption         =   "Appointment Types"
  45.       FontBold        =   0   'False
  46.       FontItalic      =   0   'False
  47.       FontName        =   "MS Sans Serif"
  48.       FontSize        =   8.25
  49.       FontStrikethru  =   0   'False
  50.       FontUnderline   =   0   'False
  51.       ForeColor       =   &H00800000&
  52.       Height          =   1755
  53.       Left            =   4500
  54.       TabIndex        =   11
  55.       Top             =   240
  56.       Width           =   1635
  57.       Begin SSPanel KindFrame 
  58.          BevelInner      =   1  'Inset
  59.          BorderWidth     =   2
  60.          ForeColor       =   &H00C0C0C0&
  61.          Height          =   675
  62.          Index           =   0
  63.          Left            =   120
  64.          TabIndex        =   15
  65.          Tag             =   "Phone"
  66.          Top             =   300
  67.          Width           =   675
  68.          Begin Image KindPict 
  69.             Height          =   480
  70.             Index           =   0
  71.             Left            =   90
  72.             Picture         =   APPTBOOK.FRX:0390
  73.             Top             =   90
  74.             Width           =   480
  75.          End
  76.       End
  77.       Begin SSPanel KindFrame 
  78.          BevelInner      =   1  'Inset
  79.          BorderWidth     =   2
  80.          ForeColor       =   &H00C0C0C0&
  81.          Height          =   675
  82.          Index           =   1
  83.          Left            =   120
  84.          TabIndex        =   14
  85.          Tag             =   "Travel"
  86.          Top             =   1020
  87.          Width           =   675
  88.          Begin Image KindPict 
  89.             Height          =   480
  90.             Index           =   1
  91.             Left            =   90
  92.             Picture         =   APPTBOOK.FRX:0692
  93.             Top             =   90
  94.             Width           =   480
  95.          End
  96.       End
  97.       Begin SSPanel KindFrame 
  98.          BevelInner      =   1  'Inset
  99.          BorderWidth     =   2
  100.          ForeColor       =   &H00C0C0C0&
  101.          Height          =   675
  102.          Index           =   2
  103.          Left            =   840
  104.          TabIndex        =   13
  105.          Tag             =   "Meeting"
  106.          Top             =   300
  107.          Width           =   675
  108.          Begin Image KindPict 
  109.             Height          =   480
  110.             Index           =   2
  111.             Left            =   90
  112.             Picture         =   APPTBOOK.FRX:0994
  113.             Top             =   90
  114.             Width           =   480
  115.          End
  116.       End
  117.       Begin SSPanel KindFrame 
  118.          BevelInner      =   1  'Inset
  119.          BorderWidth     =   2
  120.          ForeColor       =   &H00C0C0C0&
  121.          Height          =   675
  122.          Index           =   3
  123.          Left            =   840
  124.          TabIndex        =   12
  125.          Tag             =   "Lunch"
  126.          Top             =   1020
  127.          Width           =   675
  128.          Begin Image KindPict 
  129.             Height          =   480
  130.             Index           =   3
  131.             Left            =   90
  132.             Picture         =   APPTBOOK.FRX:0C96
  133.             Top             =   90
  134.             Width           =   480
  135.          End
  136.       End
  137.    End
  138.    Begin SSPanel Panel3D1 
  139.       BevelInner      =   1  'Inset
  140.       BorderWidth     =   2
  141.       Caption         =   "Panel3D1"
  142.       ForeColor       =   &H00C0C0C0&
  143.       Height          =   2655
  144.       Left            =   4500
  145.       TabIndex        =   2
  146.       Top             =   2280
  147.       Width           =   2775
  148.       Begin CommandButton SaveButton 
  149.          Caption         =   "Save"
  150.          Default         =   -1  'True
  151.          FontBold        =   0   'False
  152.          FontItalic      =   0   'False
  153.          FontName        =   "MS Sans Serif"
  154.          FontSize        =   8.25
  155.          FontStrikethru  =   0   'False
  156.          FontUnderline   =   0   'False
  157.          Height          =   375
  158.          Left            =   120
  159.          TabIndex        =   9
  160.          Top             =   780
  161.          Width           =   735
  162.       End
  163.       Begin TextBox ApptText 
  164.          BackColor       =   &H00FFFFFF&
  165.          ForeColor       =   &H00000000&
  166.          Height          =   1275
  167.          Left            =   120
  168.          MultiLine       =   -1  'True
  169.          TabIndex        =   7
  170.          Top             =   1260
  171.          Width           =   2535
  172.       End
  173.       Begin MaskEdBox ApptTime 
  174.          BackColor       =   &H00C0C0C0&
  175.          FontBold        =   0   'False
  176.          FontItalic      =   0   'False
  177.          FontName        =   "MS Sans Serif"
  178.          FontSize        =   8.25
  179.          FontStrikethru  =   0   'False
  180.          FontUnderline   =   0   'False
  181.          ForeColor       =   &H00800000&
  182.          Format          =   "hh:nn AM/PM"
  183.          Height          =   315
  184.          Left            =   1500
  185.          Mask            =   "##:## ??"
  186.          MaxLength       =   8
  187.          PromptChar      =   "_"
  188.          TabIndex        =   5
  189.          Top             =   840
  190.          Width           =   1155
  191.       End
  192.       Begin TextBox ApptType 
  193.          BackColor       =   &H00C0C0C0&
  194.          FontBold        =   0   'False
  195.          FontItalic      =   0   'False
  196.          FontName        =   "MS Sans Serif"
  197.          FontSize        =   8.25
  198.          FontStrikethru  =   0   'False
  199.          FontUnderline   =   0   'False
  200.          ForeColor       =   &H00800000&
  201.          Height          =   285
  202.          Left            =   1500
  203.          TabIndex        =   4
  204.          Top             =   480
  205.          Width           =   1155
  206.       End
  207.       Begin Image Image1 
  208.          Height          =   480
  209.          Left            =   1140
  210.          Picture         =   APPTBOOK.FRX:0F98
  211.          Top             =   60
  212.          Width           =   480
  213.       End
  214.       Begin Label Label2 
  215.          Alignment       =   1  'Right Justify
  216.          BackColor       =   &H00C0C0C0&
  217.          Caption         =   "When:"
  218.          FontBold        =   0   'False
  219.          FontItalic      =   0   'False
  220.          FontName        =   "MS Sans Serif"
  221.          FontSize        =   8.25
  222.          FontStrikethru  =   0   'False
  223.          FontUnderline   =   0   'False
  224.          Height          =   255
  225.          Left            =   900
  226.          TabIndex        =   6
  227.          Top             =   840
  228.          Width           =   555
  229.       End
  230.       Begin Label Label1 
  231.          Alignment       =   1  'Right Justify
  232.          BackColor       =   &H00C0C0C0&
  233.          Caption         =   "Appointment type:"
  234.          FontBold        =   0   'False
  235.          FontItalic      =   0   'False
  236.          FontName        =   "MS Sans Serif"
  237.          FontSize        =   8.25
  238.          FontStrikethru  =   0   'False
  239.          FontUnderline   =   0   'False
  240.          Height          =   195
  241.          Left            =   120
  242.          TabIndex        =   3
  243.          Top             =   480
  244.          Width           =   1335
  245.       End
  246.    End
  247.    Begin Image TrashCan 
  248.       Height          =   480
  249.       Left            =   6480
  250.       Picture         =   APPTBOOK.FRX:129A
  251.       Top             =   900
  252.       Width           =   480
  253.    End
  254.    Begin Image TrashOpened 
  255.       Height          =   480
  256.       Left            =   1740
  257.       Picture         =   APPTBOOK.FRX:159C
  258.       Top             =   4380
  259.       Visible         =   0   'False
  260.       Width           =   480
  261.    End
  262.    Begin Image TrashClosed 
  263.       Height          =   480
  264.       Left            =   1260
  265.       Picture         =   APPTBOOK.FRX:189E
  266.       Top             =   4380
  267.       Visible         =   0   'False
  268.       Width           =   480
  269.    End
  270.    Begin Label DragArrow 
  271.       Caption         =   "DragArrow"
  272.       DragIcon        =   APPTBOOK.FRX:1BA0
  273.       Height          =   255
  274.       Left            =   180
  275.       TabIndex        =   10
  276.       Top             =   4680
  277.       Visible         =   0   'False
  278.       Width           =   915
  279.    End
  280.    Begin Label MoveIcon 
  281.       Caption         =   "MoveIcon"
  282.       DragIcon        =   APPTBOOK.FRX:1EA2
  283.       Height          =   255
  284.       Left            =   180
  285.       TabIndex        =   8
  286.       Top             =   4380
  287.       Visible         =   0   'False
  288.       Width           =   915
  289.    End
  290.    Begin Label SaveIcon 
  291.       Caption         =   "SaveIcon"
  292.       Height          =   255
  293.       Left            =   180
  294.       TabIndex        =   1
  295.       Top             =   4080
  296.       Visible         =   0   'False
  297.       Width           =   915
  298.    End
  299.    Begin Label NoDrag 
  300.       Caption         =   "NoDrag"
  301.       DragIcon        =   APPTBOOK.FRX:21A4
  302.       Height          =   255
  303.       Left            =   180
  304.       TabIndex        =   0
  305.       Top             =   3780
  306.       Visible         =   0   'False
  307.       Width           =   915
  308.    End
  309.    Begin Menu ExitMenuOption 
  310.       Caption         =   "E&xit!"
  311.    End
  312.    Begin Menu HelpMenu 
  313.       Caption         =   "&Help"
  314.       Begin Menu HelpOption 
  315.          Caption         =   "&Index"
  316.          Index           =   1
  317.       End
  318.       Begin Menu HelpOption 
  319.          Caption         =   "&Using Help"
  320.          Index           =   2
  321.       End
  322.       Begin Menu HelpOption 
  323.          Caption         =   "-"
  324.          Index           =   3
  325.       End
  326.       Begin Menu HelpOption 
  327.          Caption         =   "&About Appointment Book..."
  328.          Index           =   4
  329.       End
  330.    End
  331. ' ---------------------------------------------------------
  332. '       Copyright (C) 1993 Apex Software Corporation
  333. ' You have a royalty-free right to use, modify, reproduce,
  334. ' and distribute the True Grid sample application files
  335. ' (and/or any modified version) in any way you find useful,
  336. ' provided that you agree that Apex Software Corporation
  337. ' has no warranty, obligations, or liability for any sample
  338. ' application files.
  339. ' ---------------------------------------------------------
  340. ' Drag mode constants to keep track of dragging activity.
  341. Dim DragType As Integer         ' type of object being dragged
  342. Dim Dragging As Integer         ' TRUE when dragging is in progress
  343. Dim DragIndex As Integer        ' Optional index of dragged obj
  344. Dim DragRow As Integer          ' Optional row being dragged in grid
  345. ' Miscellaneous variables
  346. Dim valid%                      ' used as return for DragValid
  347. ' Bitmasks to describe valid drag objects
  348. Const MASK_NEWAPPT = 1      ' a new appointment
  349. Const MASK_OLDAPPT = 2      ' an old appointment
  350. Const MASK_NONE = 0         ' mask used where no drops are allowed
  351. Sub ApptEdit ()
  352.     ' This subroutine moves the data in the current grid row into
  353.     ' the "post-it" editing area.
  354.     Dim aText As String
  355.     Dim colonPos As Integer
  356.     ' This routine copies appointment data to the edit window
  357.     aText = ApptList.ColumnText(2)
  358.     colonPos = InStr(aText, ":")
  359.     ' If no colon, there's no appointment, so clear the post-it
  360.     ' area.  If there is a colon, fill in the information.
  361.     If colonPos = 0 Then
  362.     ApptText.Text = ""
  363.     ApptTime.Text = Format$(0, ApptTime.Format)
  364.     ApptType.Text = ""
  365.     Else
  366.     ApptType.Text = Left$(aText, colonPos - 1)
  367.     ApptText.Text = Mid$(aText, colonPos + 2)
  368.     ApptTime.Text = Format$(ApptList.ColumnText(1), ApptTime.Format)
  369.     End If
  370. End Sub
  371. Sub ApptList_ColumnChange ()
  372.     ' This is to prevent the user from selecting the first column
  373.     ApptList.ColumnIndex = 2
  374. End Sub
  375. Sub ApptList_DragCell (Split As Integer, Row As Long, Col As Integer)
  376.     ' This event is intitiating when the user drags the mouse with
  377.     ' the right mouse button depressed.  If the user is in column 2
  378.     ' and there is an appointment then initiate dragging
  379.     If Col = 2 Then
  380.     ApptList.RowIndex = Row
  381.     If InStr(ApptList.Text, ":") <> 0 Then
  382.         DragRow = ApptList.RowIndex
  383.         ApptList.RefreshRow = 0
  384.         ApptList.DragIcon = MoveIcon.DragIcon
  385.         BeginDragMode ApptList, MASK_OLDAPPT
  386.     End If
  387.     End If
  388. End Sub
  389. Sub ApptList_DragDrop (Source As Control, X As Single, Y As Single)
  390.     ' Drop a new appointment or existing appointment at a new
  391.     ' row position.
  392.     Dim aText As String
  393.     Dim i%
  394.     If Not EndDragMode(MASK_NEWAPPT Or MASK_OLDAPPT) Then Exit Sub
  395.     ' Check the location of the drag and drop
  396.     ApptList.PointX = X
  397.     ApptList.PointY = Y
  398.     GridDropRow = ApptList.RowAtPoint
  399.     ' If new appointment add to grid otherwise change appt time
  400.     If DragType = MASK_NEWAPPT Then
  401.     ApptList.RowIndex = GridDropRow
  402.     ApptInfo(GridDropRow) = Source.Tag & ": "
  403.     ApptList.RefreshRow = 0
  404.     ApptEdit
  405.     Else
  406.     aText = ApptList.ColumnText(1)
  407.     ApptList.RowIndex = DragRow
  408.     i% = ChangeApptTime(TimeValue(aText))
  409.     End If
  410.     ' Clear drag row
  411.     DragRow = 0
  412.     ApptText.SetFocus
  413. End Sub
  414. Sub ApptList_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  415.     ' When dragging over the grid, both new and old appointments
  416.     ' are considered.
  417.     If Not DragValid(Source, MASK_NEWAPPT Or MASK_OLDAPPT, State) Then
  418.     Exit Sub
  419.     End If
  420.     ' Find location in the grid
  421.     ApptList.PointX = X
  422.     ApptList.PointY = Y
  423.     ' If leaving the grid set the rowindex back to the where dragging
  424.     ' started, else move the RowIndex with the drag icon.
  425.     Select Case State
  426.     Case LEAVE
  427.         ApptList.RowIndex = DragRow
  428.     Case Else
  429.         GridDropRow = ApptList.RowAtPoint
  430.         
  431.         ' If RowAtPoint is valid then move the RowIndex
  432.         If ApptList.RowAtPoint <> -1 Then
  433.         ApptList.RowIndex = ApptList.RowAtPoint
  434.         End If
  435.     End Select
  436. End Sub
  437. Sub ApptList_Fetch (Row As Long, Col As Integer, Value As String)
  438.     ' This event is the main display mechanism in callback mode
  439.     ' If in column 1 display the times.  If in column 2 query the
  440.     ' ApptInfo array and display all appointments
  441.     If Col = 1 Then
  442.     Value = ApptTimes(Row)
  443.     ElseIf Col = 2 Then
  444.     Value = ApptInfo(Row)
  445.     End If
  446.         
  447. End Sub
  448. Sub ApptList_FetchAttributes (Status As Integer, Split As Integer, Row As Long, Col As Integer, FgColor As Long, BgColor As Long, FontStyle As Integer)
  449.     ' This event lets us set attributes for given cells.  In this case
  450.     ' if the current cell has an appointment then highlight it in
  451.     ' green and white.
  452.     If InStr(ApptList.Text, ":") Then
  453.     If Status = GFS_CURCELL Then
  454.        BgColor = LTGREEN
  455.        FgColor = WHITE
  456.     End If
  457.     End If
  458.     ' If dragging is occuring then highlight the cell being
  459.     ' dragged from in blue and white.
  460.     If DragRow = Row Then
  461.     BgColor = BLUE
  462.     FgColor = WHITE
  463.     End If
  464. End Sub
  465. Sub ApptList_MarkChange (Row As Long, IsMarked As Integer)
  466.     ' In TrueGrid Pro you can now use multiple selection
  467.     ' callback mode.  The code in the MarkChange event
  468.     ' causes a select array to be updated
  469.     ApptSelect(Row) = ApptSelect(Row) Xor True
  470.     ApptList.RefreshRow = Row
  471. End Sub
  472. Sub ApptList_QueryMark (Row As Long, IsMarked As Integer)
  473.     ' Here the grid checks to see if it should highlight a
  474.     ' given row.  We provide it our array that we maintain
  475.     ' in MarkChange.
  476.     IsMarked = ApptSelect(Row)
  477. End Sub
  478. Sub ApptList_RowChange ()
  479.     ' If a RowChange occurs call ApptEdit to update Post-it area
  480.     ApptEdit
  481. End Sub
  482. Sub ApptText_DragDrop (Source As Control, X As Single, Y As Single)
  483.     valid% = EndDragMode(MASK_NONE)
  484. End Sub
  485. Sub ApptText_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  486.     valid% = DragValid(Source, MASK_NONE, State)
  487. End Sub
  488. Sub ApptTime_DragDrop (Source As Control, X As Single, Y As Single)
  489.     valid% = EndDragMode(MASK_NONE)
  490. End Sub
  491. Sub ApptTime_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  492.     valid% = DragValid(Source, MASK_NONE, State)
  493. End Sub
  494. Sub ApptTime_ValidationError (InvalidText As String, StartPosition As Integer)
  495.     ' Check for valid time if user manually changes time
  496.     MsgBox "Invalid time"
  497.     ApptTime.SetFocus
  498. End Sub
  499. Sub ApptType_DragDrop (Source As Control, X As Single, Y As Single)
  500.     ' Accept a drop only for a NEWAPPT icon, otherwise the
  501.     ' operation will be cancelled.
  502.     If EndDragMode(MASK_NEWAPPT) Then
  503.     ApptType.Text = Source.Tag
  504.     End If
  505. End Sub
  506. Sub ApptType_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  507.     valid% = DragValid(Source, MASK_NEWAPPT, State)
  508. End Sub
  509. Sub ApptType_KeyPress (KeyAscii As Integer)
  510.     ' Don't allow a colon to be entered, since we use a colon to
  511.     ' separate the appointment "kind" from the text.
  512.     If KeyAscii = Asc(":") Then
  513.     Beep
  514.     KeyAscii = 0
  515.     End If
  516. End Sub
  517. Sub BeginDragMode (ctl As Control, objType As Integer)
  518.     ' Whenever a drag is about to start, this routine is called.
  519.     ' The type mask of the drag is flagged, and we remember that
  520.     ' dragging is in progress.   This routine MUST be matched
  521.     ' by an EndDragMode function call.
  522.     DragType = objType
  523.     Dragging = True
  524.     ' Change the highlight color for the current cell to blue and white
  525.     ' while dragging is occuring
  526.     ApptList.ParamBackColor = BLUE
  527.     ApptList.ParamForeColor = WHITE
  528.     ApptList.ColumnSetStatusAttr(2) = GFS_CURCELL
  529.     ' Start the drag process
  530.     ctl.Drag BEGIN_DRAG
  531. End Sub
  532. Function ChangeApptTime (newtime As Variant) As Integer
  533.     ' Given a new time for an appointment at the current row, this
  534.     ' routine moves the appointment to the new location in the
  535.     ' grid.
  536.     Dim trow As Integer
  537.     Dim oldAppt As String
  538.     trow = TimeRow(newtime)
  539.     ' If we're already there, then do nothing and return False,
  540.     ' indicating no row change occurred.
  541.     If trow = ApptList.RowIndex Then
  542.     ChangeApptTime = False
  543.     Exit Function
  544.     End If
  545.     ' If the user entered in invalid time print an error
  546.     If trow > ApptList.Rows Or trow < 0 Then
  547.     ChangeApptTime = False
  548.     MsgBox "Invalid time"
  549.     Exit Function
  550.     End If
  551.     ChangeApptTime = True
  552.     ' Actually move the row.
  553.     oldAppt = ApptList.Text
  554.     ApptInfo(ApptList.RowIndex) = ""
  555.     ApptList.RefreshRow = 0
  556.     ApptList.RowIndex = trow
  557.     ApptInfo(ApptList.RowIndex) = oldAppt
  558.     ApptList.RefreshRow = 0
  559.     ApptEdit            ' move the data to the post-it area
  560. End Function
  561. Function DragValid (src As Control, mask As Integer, State As Integer) As Integer
  562.     ' This function is called by an object's DragOver event to
  563.     ' automatically change the drag cursor to the "no drop"
  564.     ' cursor if necessary.  It also returns True if the object
  565.     ' can legally be dropped according to the input mask.
  566.     If (mask And DragType) Then
  567.     DragValid = True
  568.     Exit Function
  569.     End If
  570.     ' This is not a valid drag.  Return False, but also change the
  571.     ' object's drag icon to the NoDrag icon (remembering the old
  572.     ' value for later restore when we exit this object).
  573.     DragValid = False
  574.     Select Case State
  575.     Case ENTER
  576.         ' Entering, remember old icon
  577.         SaveIcon.DragIcon = src.DragIcon
  578.         src.DragIcon = NoDrag.DragIcon
  579.     Case LEAVE
  580.         
  581.         ' Exiting, restore old icon
  582.         src.DragIcon = SaveIcon.DragIcon
  583.     End Select
  584. End Function
  585. Function EndDragMode (mask As Integer) As Integer
  586.     ' This function is called when a drag has ended, either
  587.     ' successfully or unsuccessfully.  This routine removes any
  588.     ' user feedback related to the drag operation and returns
  589.     ' TRUE if the passed mask matches the dragged object.
  590.     ' Set Current cell colors back to previous settings
  591.     ApptList.ParamBackColor = INHERIT_COLOR
  592.     ApptList.ParamForeColor = INHERIT_COLOR
  593.     ApptList.ColumnSetStatusAttr(2) = GFS_CURCELL
  594.     Select Case DragType
  595.     Case MASK_NEWAPPT
  596.         ' If a "new appointment" icon was dragged, change the
  597.         ' frame background to LTGREY again so that the drag
  598.         ' is officially over.
  599.         KindFrame(DragIndex).BackColor = LTGREY
  600.     Case MASK_OLDAPPT
  601.         ' If this is an item dragged from the grid, refresh
  602.         ' the grid in case the drag ended outside the grid
  603.         ' frame (and the inverted row remains).
  604.     End Select
  605.     Dragging = False
  606.     EndDragMode = (mask And DragType) <> 0
  607. End Function
  608. Sub ExitMenuOption_Click ()
  609.     'Unload forms and exit
  610.     Unload About
  611.     Unload ApptForm
  612.     End
  613. End Sub
  614. Sub Form_DragDrop (Source As Control, X As Single, Y As Single)
  615.     ' Ignore drops which occur on the form
  616.     valid% = EndDragMode(MASK_NONE)
  617. End Sub
  618. Sub Form_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  619.     ' Assure that the "no drop" icon is displayed when passing
  620.     ' over the form.
  621.     valid% = DragValid(Source, MASK_NONE, State)
  622. End Sub
  623. Sub Form_Load ()
  624.     Dim curTime As Variant
  625.     Dim curRow As Integer
  626.     Dim rowMax As Integer
  627.     ' Fill the leftmost column with appointment times.
  628.     curRow = 1
  629.     For curTime = Prefs.timeStart To Prefs.timeEnd Step Prefs.timeIncrement
  630.     ApptTimes(curRow) = Format$(curTime, "hh:mm am/pm")
  631.     curRow = curRow + 1
  632.     Next curTime
  633.     ' Set up ApptList
  634.     ApptList.SelectMode = 1  ' Enable multiple selection
  635.     rowMax = (Prefs.timeEnd - Prefs.timeStart) / Prefs.timeIncrement
  636.     ApptList.Rows = rowMax
  637.     ApptList.RowIndex = 1
  638.     ApptList.Height = (ApptList.CellRectHeight + (Screen.TwipsPerPixelY + 1)) * rowMax
  639.     ' ApptList column colors
  640.     ApptList.ColumnBackColor(1) = LTGREY     'Grey background
  641.     ApptList.ColumnBackColor(2) = OFF_YELLOW     'Yellow background
  642.     ' Forces the FetchAttributes to be called for column 2
  643.     ApptList.ColumnCellAttrs(2) = True
  644. End Sub
  645. Sub Form_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single)
  646.     ' Since we can't trap a "drop" which occurs outside of our
  647.     ' application, this is a pretty good solution.  Whenever the
  648.     ' cursor passes over the form, if we're still dragging check
  649.     ' to see if the button is now up.  If so, just cancel the
  650.     ' operation
  651.     If Dragging Then
  652.     If (Button And LEFT_BUTTON) = 0 Then
  653.         valid% = EndDragMode(MASK_NONE)
  654.     End If
  655.     End If
  656. End Sub
  657. Sub HelpOption_Click (index As Integer)
  658.     'This event calls the WinHelp EXE and a location to goto based on which selection the user has chosen
  659.     'Case 4 shows the about box for True Browser
  660.     Select Case index
  661.     Case 1
  662.         HelpContext ApptForm, HELP_APPTBOOK
  663.     Case 2
  664.         HelpOnHelp ApptForm
  665.     Case 4
  666.         About.Show 1
  667.     End Select
  668. End Sub
  669. Sub Image1_DragDrop (Source As Control, X As Single, Y As Single)
  670.     valid% = EndDragMode(MASK_NONE)
  671. End Sub
  672. Sub Image1_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  673.     valid% = DragValid(Source, MASK_NONE, State)
  674. End Sub
  675. Sub KindFrame_DragDrop (index As Integer, Source As Control, X As Single, Y As Single)
  676.     valid% = EndDragMode(MASK_NONE)
  677. End Sub
  678. Sub KindFrame_DragOver (index As Integer, Source As Control, X As Single, Y As Single, State As Integer)
  679.     valid% = DragValid(Source, MASK_NEWAPPT, State)
  680. End Sub
  681. Sub KindPict_DragDrop (index As Integer, Source As Control, X As Single, Y As Single)
  682.     valid% = EndDragMode(MASK_NONE)
  683. End Sub
  684. Sub KindPict_DragOver (index As Integer, Source As Control, X As Single, Y As Single, State As Integer)
  685.     valid% = DragValid(Source, MASK_NEWAPPT, State)
  686. End Sub
  687. Sub KindPict_MouseDown (index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
  688.     ' When the left button goes down over an "appointment type"
  689.     ' icon, drag its image in NEWAPPT mode.  Copy the DragIcon
  690.     ' each time, since it may still be set to the "no drop" icon
  691.     ' from a previous cancellation.
  692.     If Button And LEFT_BUTTON Then
  693.     KindFrame(index).DragIcon = DragArrow.DragIcon
  694.     BeginDragMode KindFrame(index), MASK_NEWAPPT
  695.     KindFrame(index).BackColor = CYAN
  696.     ' Save the index, we'll need it in EndDragMode
  697.     DragIndex = index
  698.     ApptList.RowIndex = 0
  699.     End If
  700. End Sub
  701. Sub Label1_DragDrop (Source As Control, X As Single, Y As Single)
  702.     valid% = EndDragMode(MASK_NONE)
  703. End Sub
  704. Sub Label1_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  705.     valid% = DragValid(Source, MASK_NONE, State)
  706. End Sub
  707. Sub Label2_DragDrop (Source As Control, X As Single, Y As Single)
  708.     valid% = EndDragMode(MASK_NONE)
  709. End Sub
  710. Sub Label2_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  711.     valid% = DragValid(Source, MASK_NONE, State)
  712. End Sub
  713. Sub Panel3D1_DragDrop (Source As Control, X As Single, Y As Single)
  714.     valid% = EndDragMode(MASK_NONE)
  715. End Sub
  716. Sub Panel3D1_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  717.     valid% = DragValid(Source, MASK_NONE, State)
  718. End Sub
  719. Sub Panel3D2_DragDrop (Source As Control, X As Single, Y As Single)
  720.     valid% = EndDragMode(MASK_NONE)
  721. End Sub
  722. Sub Panel3D2_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  723.     valid% = DragValid(Source, MASK_NONE, State)
  724. End Sub
  725. Sub SaveButton_Click ()
  726.     ' Save all data in the post-it area to the grid.
  727.     Dim i%
  728.     ' We can only save if there's an appointment on the current
  729.     ' grid row already (at least a blank one).
  730.     If InStr(ApptList.ColumnText(2), ":") = 0 Then
  731.     MsgBox "No appointment at current row"
  732.     Exit Sub
  733.     End If
  734.     ApptInfo(ApptList.RowIndex) = ApptType.Text & ": " & ApptText.Text
  735.     ApptList.RefreshRow = 0
  736.     ApptList.RowIndex = ApptList.RowIndex
  737.     IgnoreRowChange = False
  738.     ' If the time was changed manually, then move the row to the new
  739.     ' location.
  740.     i% = ChangeApptTime(TimeValue(ApptTime.Text))
  741. End Sub
  742. Sub SaveButton_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  743.     valid% = DragValid(Source, MASK_NONE, State)
  744. End Sub
  745. Function TimeRow (thetime As Variant) As Integer
  746.     ' Given a time value, return the row number within the grid
  747.     ' where the specified time slot is located.
  748.     TimeRow = (thetime - TimeValue("08:00am")) / TimeValue("00:30") + 1
  749. End Function
  750. Sub TrashCan_DragDrop (Source As Control, X As Single, Y As Single)
  751.     ' The trash can only accepts drops for "old appointments" from
  752.     ' the grid.
  753.     If EndDragMode(MASK_OLDAPPT) Then
  754.     ' Get rid of feedback
  755.     TrashCan.Picture = TrashClosed.Picture
  756.     ' Clear the grid row and update the post-it area
  757.     ApptInfo(ApptList.RowIndex) = ""
  758.     ApptList.RefreshRow = 0
  759.     DragRow = 0
  760.     ApptEdit
  761.     ApptList.SetFocus
  762.     End If
  763. End Sub
  764. Sub TrashCan_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  765.     ' Provide feedback by "opening the trashcan" whenever an
  766.     ' old appointment is dragged over the trash.
  767.     If DragValid(Source, MASK_OLDAPPT, State) Then
  768.     Select Case State
  769.         Case ENTER
  770.         ' Open when entering
  771.         TrashCan.Picture = TrashOpened.Picture
  772.         Case LEAVE
  773.         ' Close when leaving
  774.         TrashCan.Picture = TrashClosed.Picture
  775.     End Select
  776.     End If
  777. End Sub
  778.