For certain applications it might be necessary to limit the amount of time shown in the TimeLine like in the following example:

The timeline starts at 12:00 am December 12th, 2001.

And ends at 11:59 am December 12th, 2001.
The user can move between this 24 hour period using the HorizontalScrollBar. Important: using the HorizontalScrollBar is the only method of restricting the amount of time shown in the timeline.
To recreate this behaviour, on a new VB6 form place an MFC ActiveGantt control named ActiveGanttVCCtl1 and the following code:
Option Explicit
Private Sub ActiveGanttVCCtl1_TimeLineChanged()
Static bLoaded As Boolean
If bLoaded = False Then
Dim NumMinutes As Long
NumMinutes = DateDiff("n", ActiveGanttVCCtl1.TimeLineStart, _
ActiveGanttVCCtl1.TimeLineEnd)
ActiveGanttVCCtl1.HorizontalScrollBarStart = #12/12/2001#
ActiveGanttVCCtl1.HorizontalScrollBarInterval = "n"
ActiveGanttVCCtl1.HorizontalScrollBarFactor = 5
ActiveGanttVCCtl1.HorizontalScrollBarSmallChange = 1
ActiveGanttVCCtl1.HorizontalScrollBarLargeChange = 10
ActiveGanttVCCtl1.HorizontalScrollBarMax = ((1440 / 5) - (NumMinutes / 5))
ActiveGanttVCCtl1.HorizontalScrollBarEnabled = True
bLoaded = True
End If
End Sub
|
Because of the way the MFC control is drawn it cannot calculate the value of TimeLineEnd in a Form_Load procedure, so the bLoaded variable becomes necessary and the TimeLineChanged event must be used.
In this case in particular, the ActiveGantt Control will display a 24-hour period beginning on 12/12/2001 12:00AM and ending just before 12/13/2001. 1440 is the number of minutes in 24 hours, the horizontal scroll bar moves in increments of 5 minutes (because of the HorizontalScrollBarFactorproperty), and the max property setting is determined by the amount of minutes in a 24h period (divided by the HorizontalScrollBarFactor) minus the NumMinutes variable (again divided by the HorizontalScrollBarFactor).