[Gambas-user] Issue with a Bains line
Rolf-Werner Eilert
rwe-sse at osnanet.de
Thu Sep 6 10:50:50 CEST 2018
Am 06.09.2018 um 09:33 schrieb Rolf-Werner Eilert:
> There is a strange behaviour in calculating the position of a Bains line
> over a timetable.
>
> Long time ago, I came across this problem in my calendar program, but
> thanks to a tip by Benoit I came easily over it. To make clear what I
> mean, here is the code which runs well.
>
> The timetable is a GridView called "wo":
>
> wo.Row = Hour(Now)
>
> baines.Y = wo.Current.Y - wo.ScrollY + wo.ClientY + ((wo.Current.Height
> / 60) * Minute(Now))
>
> The GridView just begins with 0 and runs up to 23, so it's easy: every
> hour has a cell.
>
> Now I have a timetable for our school. Every cell has 45 minutes, and
> there are breaks between them, so you cannot compute directly from time
> to position. Instead, there is a list of starting times for each lesson.
>
> First the current cell is set to the lesson according to the list (a
> small function does this and delivers "zeile") then:
>
> .Row = zeile
>
> Up to here it runs flawlessly, but then computing doesn't find a proper
> position for the Bains line:
>
> bains1.Y = .Current.Y - .ScrollY + .ClientY + ((.Current.Height /
> 45) * Abs(CInt(DateDiff(Now, Date(Year(Now), Month(Now), Day(Now), st,
> mn, 0, 0), gb.Minute))))
>
> This long Abs(CInt... thing runs well, I checked for it. The correct
> number of minutes from the beginning of the lesson until Now is
> delivered. Everything boils down to
>
> bains1.Y = .CurrentY - .ScrollY + .ClientY + ((.Current.Height / 45) *
> <Number of minutes until now)
>
> At this time of the day, the Bains line lands far behind (above) the
> cells it should be in, and later it lands too far beyond (below) them.
> It never really hits the cell or a proper position.
>
> In the program, there are 6 GridViews with a Bains line, and the
> deviation is the same for all of them.
>
> So where is the problem? Thank you for any hint!
>
> Rolf
>
I have to answer myself because I found a possible reason for the
trouble. There is a Panel in the program up at the top of the form. When
I calculate its height into the position, the result seems to be ok:
bains1.Y = Panel1.H + .CurrentY...
How does a Panel's height fail to be counted? There are Labels above the
GridViews which do not fail, the GridViews and there cells are found
correctly. It seems as if the GridViews are shown correctly themselves
but actually do not get correct values from the form (maybe an error in
the Form class?).
Regards
Rolf
More information about the User
mailing list