写一个体彩走势图的控件
(走势图,各期开奖结果列表)THistory从TCustomControl继承
(开奖结果,也就是红点)THistoryItem是从TGraphicControl继承下来的
(两边显示的“期数”“总和”“距离”等)THistoryText也是从TGraphicControl继承。走势图根据选择的彩票类型进行动态变化,刚开始的时候都没问题(下面的第一副图),可变化一段时间后就成第二副图的样了,THistoryItem全部看不见了,还有THistoryText除了在最左边的“期数”可以看到,右边的那部分也全看不见了。调试的时候发现THistoryItem里面PAINT函数都不执行已经两天了都找不出原因。郁闷死了。
(走势图,各期开奖结果列表)THistory从TCustomControl继承
(开奖结果,也就是红点)THistoryItem是从TGraphicControl继承下来的
(两边显示的“期数”“总和”“距离”等)THistoryText也是从TGraphicControl继承。走势图根据选择的彩票类型进行动态变化,刚开始的时候都没问题(下面的第一副图),可变化一段时间后就成第二副图的样了,THistoryItem全部看不见了,还有THistoryText除了在最左边的“期数”可以看到,右边的那部分也全看不见了。调试的时候发现THistoryItem里面PAINT函数都不执行已经两天了都找不出原因。郁闷死了。
procedure THistory.SetItemInf(const Value: TItemInf);
var
I: Integer;
begin
if Value.RecordCount > FItemInf.RecordCount then
begin
SetLength(FItems, Value.RecordCount);
for I := FItemInf.RecordCount to Value.RecordCount-1 do
begin
FItems[I] := THistoryItem.Create(self);
end;
end;
if FItemInf.RecordCount > Value.RecordCount then
begin
for I := Value.RecordCount to FItemInf.RecordCount-1 do
begin
FItems[I].Free;
end;
SetLength(FItems, Value.RecordCount);
end; {//////////////////////////////////////
for I := 0 to FItemInf.RecordCount-1 do
begin
FItems[I].Free;
end;
SetLength(FItems, Value.RecordCount);
for I:= 0 to Value.RecordCount-1 do
begin
FItems[I] := THistoryItem.Create(self);
end;
//////////////////////////////////////// } FItemInf.RecordCount := Value.RecordCount;
for I := 0 to FItemInf.RecordCount-1 do
begin
FItemInf.Records[I] := Value.Records[I];
FItems[I].Number := Value.Records[I];
end;
SetPosition;
end;//这个是用来设置他们的位置的。调试的时候位置都没问题。procedure THistory.SetPosition;
var
I: Integer;
ItemPoint: TPoint;
begin
FIndex.Width := GetHistoryIndexWidth(FItemWidth);
FTotal.Width := GetHistoryItemWidth(FItemWidth);
FParity.Width := FTotal.Width;
FRepeat.Width := FTotal.Width;
FDistance.Width := FTotal.Width;
FIndex.Height := FItemHeight;
FTotal.Height := FItemHeight;
FParity.Height := FItemHeight;
FRepeat.Height := FItemHeight;
FDistance.Height := FItemHeight; FIndex.Left := 0;
FTotal.Left := FIndex.Width + ItemWidth*FItemCount;
FParity.Left := FTotal.Left + FTotal.Width -1;
FRepeat.Left := FParity.Left + FParity.Width -1;
FDistance.Left := FRepeat.Left + FRepeat.Width -1; for I := 0 to ItemInf.RecordCount-1 do
begin
FItems[I].Width := FItemWidth-2;
FItems[I].Height := FItemHeight-2;
ItemPoint := GetItemPoint(FItems[I].Number);
FItems[I].Left := ItemPoint.X;
FItems[I].Top := ItemPoint.Y;
end; Width := FDistance.Left + FDistance.Width;
Height := ItemHeight;
end;
begin
inherited;
if bResetTextPoint then SetTextPoint;
with Canvas do
begin
if Number > 0 then begin
ColorOld := Brush.Color;
Brush.Color := clRed;
FillRgn(Handle, Rgn, Brush.Handle);
Brush.Color := ColorOld;
StyleOld := Brush.Style;
Brush.Style := bsClear;
TextOut(PointText.X, PointText.Y, IntToStr(Number));
Brush.Style := StyleOld;
end;
end;
end;