Einzelnen Beitrag anzeigen

appolode

Registriert seit: 28. Sep 2008
Ort: berlin
7 Beiträge
 
Delphi 7 Enterprise
 
#7

AW: delphi zugriffsverletzung bei adresse in modul. lesen von adresse

  Alt 25. Jul 2010, 13:48
Hallo,
den Fehler taucht in folgendem Teil:

for R := FixedCols to ColCount - 1 do
begin
RH := ColWidths[R];
if R < LeftCol then
Inc(TotalHiddenWidth,RH + GLW);
Inc(TotalScrollableWidth,RH + GLW);
end;

aus

Delphi-Quellcode:
procedure TAdvStringGrid.UpdateHScroller;
var
  R,GLW,RH,TCW: Integer;
  TotalFixedWidth: Integer;
  TotalScrollableWidth: Integer;
  TotalHiddenWidth: Integer;
  ViewRatio: Single;
  IdealNMax: Single;
  IdealNPos: Single;
  ScrollInfo: TScrollInfo;
begin
  if (csLoading in ComponentState) or
     (csDesigning in ComponentState) then
    Exit;

  if not ScrollProportional then
    Exit;

  if FScrollLock then
    Exit;

  { Get current scroll information }
  {$IFNDEF TMSDOTNET}
  FillChar(ScrollInfo,SizeOf(ScrollInfo),0);
  {$ENDIF}

  {$IFDEF TMSDOTNET}
  ScrollInfo.cbSize := Marshal.SizeOf(TypeOf(ScrollInfo));
  {$ENDIF}
  {$IFNDEF TMSDOTNET}
  ScrollInfo.cbSize := SizeOf(ScrollInfo);
  {$ENDIF}

  ScrollInfo.FMask := SIF_ALL;
  GetScrollInfo(Handle,SB_HORZ,ScrollInfo);

  { Calculate proper scrolling region ratio }
  GLW := GridLineWidth;

  TotalFixedWidth := GLW;
  for R := 0 to FixedCols - 1 do
  begin
    Inc(TotalFixedWidth,ColWidths[R] + GLW);
  end;

  TotalScrollableWidth := GLW;
  TotalHiddenWidth := GLW;
  [B][COLOR="Red"]for R := FixedCols to ColCount - 1 do
  begin
    RH := ColWidths[R];
    if R < LeftCol then
      Inc(TotalHiddenWidth,RH + GLW);
    Inc(TotalScrollableWidth,RH + GLW);
  end;[/COLOR][/B]

  TCW := 0;
  for R := 0 to ColCount - 1 do
    TCW := TCW + ColWidths[R];

  ViewRatio := (Width - TotalFixedWidth)/TotalScrollableWidth;

  if (ViewRatio >= 0.9999) then
    Exit;

  IdealNMax := (127 + ViewRatio) / (1 - ViewRatio);

  if (TotalScrollableWidth > Width) then
    IdealNPos := TotalHiddenWidth / (TotalScrollableWidth - Width) * 128
  else
    IdealNPos := ScrollInfo.nPos;

  { Set scroll information }
  ScrollInfo.nMax := Trunc(IdealNMax);
  ScrollInfo.nPage := ScrollInfo.nMax - 127 + 1;
  ScrollInfo.nPos := Trunc(IdealNPos);

  SetScrollInfo(Handle,SB_HORZ,ScrollInfo,TRUE);

  UpdateHScrollBar;

  // total column width smaller than grid width or no horiz. scrollbar selected, hide the scrollbar
  if (ScrollBarAlways in [saNone, saVert]) then
    if (TCW < Width) or not (ScrollBars in [ssHorizontal,ssBoth]) then
      ShowScrollBar(Handle,SB_HORZ,False);
end;

Geändert von mkinzler (25. Jul 2010 um 14:13 Uhr) Grund: Code-Tag durch Delphi-Tag ersetzt
  Mit Zitat antworten Zitat