function CreateHexDump(AOwner: TWinControl): THexDump;
implementation
{ Form Methods }
function CreateHexDump(AOwner: TWinControl): THexDump; begin
Result := THexDump.Create(AOwner); with Result do begin
Parent := AOwner;
Font.Name := 'FixedSys';
ShowCharacters := True;
Align := alClient; end; end;
destructor THexDump.Destroy; begin inherited Destroy; end;
procedure THexDump.CreateParams(var Params: TCreateParams); begin inherited CreateParams(Params); with Params do begin if FBorder = bsSingle then
Style := Style or WS_BORDER;
Style := Style or WS_VSCROLL; end; end;
begin if FItemHeight < 1 then Exit;
FVisibleLines := (ClientHeight div FItemHeight) + 1;
CharsPerLine := ClientWidth div FItemWidth; if FShowAddress then Dec(CharsPerLine, 10);
FBytesPerLine := CharsPerLine div Divisor[FShowCharacters]; if FBytesPerLine < 1 then
FBytesPerLine := 1 elseif FBytesPerLine > MAXDIGITS then
FBytesPerLine := MAXDIGITS;
FLineCount := (DataSize div FBytesPerLine); ifBoolean(DataSize mod FBytesPerLine) then Inc(FLineCount); end;
function THexDump.ScrollIntoView: Boolean; begin
Result := False; if FCurrentLine < FTopLine then begin
Result := True;
SetTopLine(FCurrentLine); end elseif FCurrentLine >= (FTopLine + FVisibleLines) - 1 then begin
SetTopLine(FCurrentLine - (FVisibleLines - 2));
Result := True; end; end;
procedure THexDump.SetTopLine(Value: Integer); var
LinesMoved: Integer;
R: TRect; begin if Value <> FTopLine then begin if Value < 0 then Value := 0; if Value >= FLineCount then Value := FLineCount - 1;
if LinesMoved = -1 then begin
R.Top := ClientHeight - FItemHeight;
R.Bottom := ClientHeight; end else begin
R.Top := 0;
R.Bottom := FItemHeight; end;
InvalidateRect(Handle, @R, False);
end else Invalidate; end; end;
procedure THexDump.SetCurrentLine(Value: Integer); var
R: TRect; begin if Value <> FCurrentLine then begin if Value < 0 then Value := 0; if Value >= FLineCount then Value := FLineCount - 1;
if (FCurrentLine >= FTopLine) and (FCurrentLine < FTopLine + FVisibleLines - 1) then begin
R := Bounds(0, 0, 1, FItemHeight);
OffsetRect(R, 0, (FCurrentLine - FTopLine) * FItemHeight);
Windows.InvalidateRect(Handle, @R, True); end;
FCurrentLine := Value;
procedure THexDump.MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); begin inherited MouseDown(Button, Shift, X, Y); ifnot Focused then SetFocus; if (Button = mbLeft) and FActive then
CurrentLine := FTopLine + (Y div FItemHeight); end;
{ PropertySet/Get Routines }
procedure THexDump.SetBorder(Value: TBorderStyle); begin if Value <> FBorder then begin
FBorder := Value;
RecreateWnd; end; end;
procedure THexDump.SetShowAddress(Value: Boolean); begin if FShowAddress <> Value then begin
FShowAddress := Value;
Invalidate; end; end;
procedure THexDump.SetShowCharacters(Value: Boolean); begin if Value <> FShowCharacters then begin
FShowCharacters := Value;
Invalidate; end; end;
procedure THexDump.SetFileColor(Index: Integer; Value: TColor); begin if FFileColors[Index] <> Value then begin
FFileColors[Index] := Value;
Invalidate; end; end;
function THexDump.GetFileColor(Index: Integer): TColor; begin
Result := FFileColors[Index]; end;
procedure THexDump.SetAddress(Value: Pointer); begin
FActive := Value <> nil;
FAddress := Value;
Invalidate; end;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.