Navigation bar
  Home Print document Start Previous page
 151 of 234 
Next page End  

Gravitybox Schedule Primer
Page 149 
1998-2004 Gravitybox Software LLC
Chapter 15
OtherDrop Example
The next example is deceptively simple. It is just over 20
lines of code but still merits the definition of an application
that performs a complicated action. There are times when
you will want to add appointments from some external source. You may not want the
user to click to add appointments at all. This example has one form with a schedule and
a list box. The list box is populated with people, clients, trucks, or whatever. You want to
drag an item from the list and have it appear on the schedule with the proper text
displayed. For this example I have hard-coded the list items. You could of course load it
from anywhere, preferably your database of patients. I have three items in it. In order to
drag an item and drop it on a schedule you will need to add a little code.
Option Explicit
Private Sub Form_Load()
  Call List1.AddItem("Father Time")
  Call List1.AddItem("Jack Frost")
  Call List1.AddItem("Mother Nature")
End Sub
Private Sub List1_MouseDown(Button As Integer, Shift As
Integer, X As Single, Y As Single)
  Call List1.OLEDrag
End Sub
Private Sub List1_OLESetData(Data As DataObject, _
                      DataFormat As Integer)
  Call Data.SetData(Schedule1.CreateByteArray("90"), _
                      Schedule1.OLEDragFormat)
End Sub
Private Sub List1_OLEStartDrag(Data As DataObject, _
                       AllowedEffects As Long)
  Call Data.SetData(, Schedule1.OLEDragFormat)
  AllowedEffects = vbDropEffectCopy
End Sub
Private Sub Schedule1_AfterAdd(ByVal NewIndex As Long)
  Schedule1.ScheduleItems(NewIndex).DisplayText = List1.Text
End Sub
Quick Tip
You may drop a non-schedule object
on a schedule if needed to create an
appointment if necessary.
http://www.purepage.com