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:
Private Sub ActiveGanttVBNCtl1_TimeLineChanged() Handles ActiveGanttVBNCtl1.TimeLineChanged
Static bLoaded As Boolean
If bLoaded = False Then
Dim NumMinutes As Long
TextBox1.Text = ActiveGanttVBNCtl1.TimeLineStart
TextBox2.Text = ActiveGanttVBNCtl1.TimeLineEnd
NumMinutes = DateDiff("n", ActiveGanttVBNCtl1.TimeLineStart, _
ActiveGanttVBNCtl1.TimeLineEnd)
ActiveGanttVBNCtl1.HorizontalScrollBarStart = #12/12/2001#
ActiveGanttVBNCtl1.HorizontalScrollBarInterval = "n"
ActiveGanttVBNCtl1.HorizontalScrollBarFactor = 5
ActiveGanttVBNCtl1.HorizontalScrollBarSmallChange = 1
ActiveGanttVBNCtl1.HorizontalScrollBarLargeChange = 10
ActiveGanttVBNCtl1.HorizontalScrollBarMax = ((1440 / 5) - (NumMinutes / 5)) + 10
ActiveGanttVBNCtl1.HorizontalScrollBarEnabled = True
bLoaded = True
End If
End Sub
|
Because of the way the VB.Net 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). Because of the way the scroll bars work in vb.Net 10 must be added (the value of HorizontalScrollBarLargeChange).