In de resize van mijn form gebruik ik dit:
Code:
If FObjectList.Count > 0 then
begin
For I := 0 to FObjectList.Count-1 do
begin
A := Ceil(DateTimeToJulianDate(StrToDateTime(Grid.Cells[2,I+1])-Z));
B := GridTag;
C := GridColWidth+1;
D := Ceil(DateTimeToJulianDate(StrToDateTime(Grid.Cells[4,I+1])-Z));
P := StrToInt(Grid.Cells[17,I+1]);
VC := StrToFloat(Grid.Cells[15,I+1]);
NC := StrToFloat(Grid.Cells[16,I+1]);
X := -((B-1)*C)+((A-StartGrid)*C)+2; //2452105 Dit is de beginpositie van de balk
Y := C*(D-A+1)-1; // Dit is de lengte van de balk
TGRBPlanLabel(FindComponent('PlanLabel' + IntToStr(I))).Height := 13;
TGRBPlanLabel(FindComponent('PlanLabel' + IntToStr(I))).ColWidth := GridColWidth;
TGRBPlanLabel(FindComponent('PlanLabel' + IntToStr(I))).Position := A;
TGRBPlanLabel(FindComponent('PlanLabel' + IntToStr(I))).Left := X;
If P > 100 then
TGRBPlanLabel(FindComponent('PlanLabel' + IntToStr(I))).Width := Y + (C * Floor((NC-VC) / 7.6))
else
TGRBPlanLabel(FindComponent('PlanLabel' + IntToStr(I))).Width := Y;
end;
end;
Paintbox2.Refresh;
In de label zelf heb ik het draggen en strechen opgenomen:
Code:
procedure TGRBPlanLabel.MouseUp(Button: TMouseButton; Shift: TShiftState; X: Integer; Y: Integer);
var
Z: Integer;
Tijd: String;
begin
FDragKind := dkNone;
If (Left <> OldLeft) or (Width <> OldWidth) then
begin
Tijd := FormatDateTime('hh', Now);
If StrToInt(Tijd) >= 12 then
Z := StrToInt('0')
else
Z := StrToInt('1');
with TCrack(Self) do
begin
drawHandle(Self,true);
If (Left <> OldLeft) or (Width <> OldWidth) then
begin
If Left > OldLeft then
begin
FPosition := FPosition + Ceil((Left-OldLeft)/(FGridColWidth+1));
FPlanWidth := FPosition + Ceil(Width/(FGridColWidth+1))-1;
end
else
begin
FPosition := FPosition - Ceil((OldLeft-Left)/(FGridColWidth+1));
FPlanWidth := FPosition + Ceil(Width/(FGridColWidth+1))-1;
end;
If Width > OldWidth then
begin
FPlanWidth := FPosition + Ceil(Width/(FGridColWidth+1))-1;
end
else
begin
FPlanWidth := FPosition + Ceil(Width/(FGridColWidth+1))-1;
end;
end;
end;
FStartDatum := FPosition+Z;
FEindDatum := FPlanWidth+Z;
FDuur := EindDatum - StartDatum;
FChanged := True;
end;
inherited;
end;
Ik houd er rekening mee of het event voor of na de middag gebeurt i.v.m. de juliandate
Bookmarks