Tüm Platformlar için Hızlı Uygulama Geliştirme --->    Kitabımız...      Delphi

Konuyu Paylaş : facebook gplus twitter

Konuyu Oyla:
  • Derecelendirme: 0/5 - 0 oy
  • 1
  • 2
  • 3
  • 4
  • 5
Listview item ekleme problemi boş olarak görünüyor
#1
Listview item ekledigi halde boş olarak görünüyor breakpoint koyarak baktım eklemesi lazım ama Listview boş olarak görünüyor.

çağırma kodum :

procedure TForm1.Button2Click(Sender: TObject);
var
 im: string;
 item:  TListItem;
begin
   with TOpenDialog.Create(self) do
 try
   Filter := 'Text files (*.txt)|*.txt|Tüm Dosyalar (*.*)|*.*';
   if Execute then
   begin
     ListView1.Items.Count := 0;
     FTab := TTabStringsFile.Open(FileName); // Unit aşağıda
     ListView1.Items.Count := FTab.Count;
     Caption := FileName;
   end;
 finally
   Free;
 end;
   yukleme(ListView1);
end;


yazdığım procedure şu şekilde

procedure TForm1.yukleme(const ListView: TListView);
var
 item :TListItem;
begin
  item:= ListView1.Items.Add;
  item.Caption := IntToStr(Item.Index);
  Item.SubItems.Add(FTab[Item.Index]);
end;

Kullandığım ünit

unit tabfile;

interface

uses windows, sysutils, classes;

type

  TAccessMode = (amReadOnly, amReadWrite);

  ETabFileError = class(Exception)
  end;

  ETabStringsFileError = class(ETabFileError)
  end;


  ITabFile = interface

     function GetPtr: PChar;

     function Offset(offset: LongWord): Pointer;

     function GetSize: LongWord;

     procedure SetSize(v: LongWord);

     function GetContent(pos: LongWord): Char;

     procedure SetContent(pos: LongWord; const Value: Char);

     function GetStringAccess(pos: LongWord): String;

     procedure SetStringAccess(pos: LongWord; const Value: String);

     procedure OpenFile(fileName: TFileName; accessMode: TAccessMode=amReadWrite);

     procedure CreateFile(fileName: TFileName; tabSize: LongWord; bOverwrite: boolean=true);

     procedure CloseFile;

     function IsReadOnly: boolean;

     procedure Insert(pos: LongWord; sizebloc: LongWord; fill: byte=0);

     procedure Append(sizebloc: LongWord; fill: byte=0);

     procedure Delete(pos: LongWord; sizebloc: LongWord);

     property Size: LongWord read GetSize write SetSize;

     property Ptr: PChar read GetPtr;

     property Content[pos: LongWord]: Char read GetContent write SetContent; default;

     property StringAccess[pos: LongWord]: String read GetStringAccess write SetStringAccess;

     property ReadOnly: boolean read IsReadOnly;
  end;

  ITabStringsFile = interface

     function GetFileSize: LongWord;
     function GetTextStr: string;
     procedure SetTextStr(const Value: string);
     function Get(Index: LongWord): string;
     procedure Put(Index: LongWord; const S: string);
     function GetCount: LongWord;
     function Add(const S: string): LongWord;
     procedure AddStrings(Strings: TStrings); overload;
     procedure AddStrings(Strings: ITabStringsFile); overload;
     procedure Clear;
     procedure Delete(Index: DWord);
     function Equals(Strings: ITabStringsFile): Boolean;
     procedure Exchange(Index1, Index2: LongWord);
     function GetText: PChar;
     function IndexOf(const S: string): LongWord;
     function Search(const S: string; Index: LongWord=0): LongWord;
     function OffsetIndex(offset: LongWord): LongWord;
     procedure Insert(Index: LongWord; const S: string);
     procedure LoadFromFile(const FileName: string);
     procedure LoadFromStream(Stream: TStream);
     procedure Move(CurIndex, NewIndex: LongWord);
     procedure SaveToFile(const FileName: string);
     procedure SaveToStream(Stream: TStream);
     procedure SetText(Text: PChar);
     property Count: LongWord read GetCount;
     property Strings[Index: LongWord]: string read Get write Put; default;
     property Text: string read GetTextStr write SetTextStr;
     property FileSize: LongWord read GetFileSize;
  end;

  TInternalTabFile = class(TInterfacedObject)
  private
     FFileHandle: THandle;
     FMap: THandle;
     FPtr: PChar;
     FAccessMode: TAccessMode;
     FSize: LongWord;

  protected
     procedure CheckBounds(pos: LongWord);
     procedure CheckReadOnly;
     procedure CheckOpen;
     function GetPtr: PChar;
     function GetSize: LongWord;
     procedure SetSize(v: LongWord);
     procedure InternalSetSize(v: LongWord);
     function GetContent(pos: LongWord): Char;
     procedure SetContent(pos: LongWord; const Value: Char);
     function GetStringAccess(pos: LongWord): String;
     procedure SetStringAccess(pos: LongWord; const Value: String);
     procedure MapFileToTab;
     procedure UnmapFile;
     procedure CalcFileSize;
     procedure OpenFile(fileName: TFileName; accessMode: TAccessMode=amReadWrite); virtual;
     procedure CreateFile(fileName: TFileName; tabSize: LongWord; bOverwrite: boolean=true); virtual;
     procedure CloseFile; virtual;


     procedure Insert(pos: LongWord; sizebloc: LongWord; fill: byte=0);
     procedure Append(sizebloc: LongWord; fill: byte=0);
     procedure Delete(pos: LongWord; sizebloc: LongWord);

     function IsReadOnly: boolean;
     property Size: LongWord read GetSize write SetSize;
     property Content[pos: LongWord]: Char read GetContent write SetContent; default;
     property StringAccess[pos: LongWord]: String read GetStringAccess write SetStringAccess;

  public
     destructor Destroy; override;
  end;

  TTabFile = class(TInternalTabFile, ITabFile)
  public
     constructor Open(fileName: TFileName; accessMode: TAccessMode=amReadWrite);
     constructor CreateNew(fileName: TFileName; tabSize: LongWord; bOverwrite: boolean=true);
     function Offset(off: longWord): pointer;
  end;

  TLineSeparator = (lsUndef, lsCR, lsLF, lsCRLF);

  TTabStringsFile = class(TInternalTabFile, ITabStringsFile)
  private
     FLines: TList;
     FLineSeparator: TLineSeparator;
     FLineSeparatorStr: PChar;
     FLineSeparatorSize: longword;
     FLastLineSeparator: Boolean;
     procedure SetLineSeparator(const Value: TLineSeparator);

     procedure CheckTabBounds(index: Longword);
     procedure GetLineInfos(index: Longword; var pos: Longword; var len: Longword);
     procedure GetLineInfosSep(index: Longword; var pos: Longword; var len: Longword);

     function GetFileSize: LongWord;
     function Search(const S: string; Index: LongWord=0): LongWord;
     function OffsetIndex(offset: LongWord): LongWord;

     //
     function GetTextStr: string;
     procedure SetTextStr(const Value: string);
     function Get(Index: LongWord): string;
     procedure Put(Index: LongWord; const S: string);
     function GetCount: LongWord;
     //////////////////////////////
     function Add(const S: string): LongWord;
     procedure AddStrings(Strings: TStrings); overload;
     procedure AddStrings(Strings: ITabStringsFile); overload;
     procedure Clear;
     procedure Delete(Index: DWord);
     function Equals(Strings: ITabStringsFile): Boolean;
     procedure Exchange(Index1, Index2: LongWord);
     function GetText: PChar;
     function IndexOf(const S: string): LongWord;
     procedure Insert(Index: LongWord; const S: string);
     procedure LoadFromFile(const FileName: string);
     procedure LoadFromStream(Stream: TStream);
     procedure Move(CurIndex, NewIndex: LongWord);
     procedure SaveToFile(const FileName: string);
     procedure SaveToStream(Stream: TStream);
     procedure SetText(Text: PChar);

     procedure Init;
     procedure InitLignes;

  public
     constructor Open(fileName: TFileName; accessMode: TAccessMode=amReadWrite);
     constructor CreateNew(fileName: TFileName; ls: TLineSeparator; bOverwrite: boolean=true);
     destructor Destroy; override;
     property LineSeparator: TLineSeparator read FLineSeparator write SetLineSeparator;
  end;

implementation


{$DEFINE BMSEARCH}

{$IFDEF BMSEARCH}
uses bmsearch;
{$ENDIF}


function DWChoose(cond: Boolean; dw1, dw2: DWord): DWord;
begin
  if cond then result := dw1 else result := dw2;
end;

constructor TTabFile.Open(fileName: TFileName;
  accessMode: TAccessMode=amReadWrite);
begin
  inherited Create;
  OpenFile(fileName, accessMode);
end;

constructor TTabFile.CreateNew(fileName: TFileName; tabSize: LongWord; bOverwrite: boolean=true);
begin
  inherited Create;
  CreateFile(fileName, tabSize, bOverwrite);
end;

destructor TInternalTabFile.Destroy;
begin
  CloseFile;
  inherited;
end;

function TInternalTabFile.IsReadOnly: boolean;
begin
  result := FAccessMode = amReadOnly;
end;

function TInternalTabFile.GetContent(pos: LongWord): Char;
begin
  result := FPtr[pos];
end;

procedure TInternalTabFile.SetContent(pos: LongWord; const Value: Char);
begin
  FPtr[pos] := Value;
end;

function TInternalTabFile.GetSize: LongWord;
begin
  result := FSize;
end;

function TInternalTabFile.GetPtr: PChar;
begin
  result := FPtr;
end;

procedure TInternalTabFile.CheckBounds(pos: LongWord);
begin
  if pos>=FSize then
     raise ETabFileError.CreateFmt('Indice %d hors limites', [pos]);
end;

procedure TInternalTabFile.CheckReadOnly;
begin
  if IsReadOnly then
     raise ETabFileError.Create('Impossible de changer la taille d''un tableau en lecture seule');
end;

procedure TInternalTabFile.OpenFile(fileName: TFileName; accessMode: TAccessMode);
begin
  CloseFile;
  FAccessMode := accessMode;

  FFileHandle := Windows.CreateFile(PChar(fileName),
     DWChoose(IsReadOnly, GENERIC_READ, GENERIC_READ Or GENERIC_WRITE),
     FILE_SHARE_READ, NIL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
  if FFileHandle=INVALID_HANDLE_VALUE then
     raise ETabFileError.CreateFmt('Erreur [%x] à l''ouverture de %s', [GetLastError, fileName]);


  CalcFileSize;
  MapFileToTab;
end;

//
//
procedure TInternalTabFile.CloseFile;
begin
  UnmapFile;
  if FFileHandle<>0 then
     CloseHandle(FFileHandle);
  FFileHandle := 0;
end;

procedure TInternalTabFile.MapFileToTab;
begin
  CheckOpen;
  if FSize<>0 then
     try
        FMap := CreateFileMapping(FFileHandle, NIL,
           DWChoose(IsReadOnly, PAGE_READONLY, PAGE_READWRITE),
           0, 0, NIL);
        if FMap=0 then
           raise ETabFileError.CreateFmt('Erreur [%x] avec CreateFileMapping', [GetLastError]);

        FPtr := MapViewOfFile(FMap,
           DWChoose(IsReadOnly, FILE_MAP_READ, FILE_MAP_ALL_ACCESS),
           0, 0, 0);
        if FPtr=Nil then
           raise ETabFileError.CreateFmt('Erreur [%x] avec MapViewOfFile', [GetLastError]);
     except
        UnmapFile;
        raise;
     end;
end;

procedure TInternalTabFile.UnmapFile;
begin
  if FPtr<>Nil then
     UnmapViewOfFile(FPtr);
  FPtr := Nil;
  if FMap<>0 then
     CloseHandle(FMap);
  FMap := 0;
end;

procedure TInternalTabFile.CalcFileSize;
begin
  FSize := GetFileSize(FFileHandle, Nil);
  if FSize=$FFFFFFFF then
     raise ETabFileError.CreateFmt('Erreur [%x] avec GetFileSize', [GetLastError]);
end;

procedure TInternalTabFile.InternalSetSize(v: LongWord);
begin
  SetFilePointer(FFileHandle, v, Nil, FILE_BEGIN);
  SetEndOfFile(FFileHandle);
  CalcFileSize;
end;

procedure TInternalTabFile.SetSize(v: LongWord);
begin
  CheckReadOnly;
  UnmapFile;
  InternalSetSize(v);
  MapFileToTab;
end;

procedure TInternalTabFile.CheckOpen;
begin
  if FFileHandle=0 then
     raise ETabFileError.Create('Fichier non ouvert');
end;

procedure TInternalTabFile.CreateFile(fileName: TFileName; tabSize: LongWord; bOverwrite: boolean);
begin
  CloseFile;
  FAccessMode := amReadWrite;

  FFileHandle := Windows.CreateFile(PChar(fileName),
     DWChoose(IsReadOnly, GENERIC_READ, GENERIC_READ Or GENERIC_WRITE),
     FILE_SHARE_READ, NIL,
     DWChoose(bOverwrite, CREATE_ALWAYS, CREATE_NEW),
     FILE_ATTRIBUTE_NORMAL, 0);
  if FFileHandle=INVALID_HANDLE_VALUE then
     raise ETabFileError.CreateFmt('Erreur [%x] à là création de %s', [GetLastError, fileName]);

  InternalSetSize(tabSize);

  MapFileToTab;
end;

function TInternalTabFile.GetStringAccess(pos: LongWord): String;
var
  i: DWord;
begin
  CheckBounds(pos);

  i := Pos;
  while (i<FSize) And (FPtr[i]<>#$d) And (FPtr[i]<>#$a) do
     inc(i);
  SetString(Result, FPtr+pos, i-pos);
end;

procedure TInternalTabFile.SetStringAccess(pos: LongWord; const Value: String);
begin
  CheckBounds(pos+LongWord(Length(Value)));
  MoveMemory(FPtr+Pos, PChar(Value), Length(Value));
end;

procedure TInternalTabFile.Insert(pos, sizebloc: LongWord; fill: byte);
var
  oldsize: LongWord;
begin
  CheckReadOnly;

  if pos=FSize then
     Append(sizebloc, fill)
  else
  begin
     CheckBounds(pos);

     oldsize := Size;
     Size := oldsize + sizebloc;
     MoveMemory(FPtr + pos +sizebloc, FPtr + pos, oldsize-pos);
     FillMemory(FPtr + pos, sizebloc, fill);
  end;
end;

procedure TInternalTabFile.Append(sizebloc: LongWord; fill: byte);
var
  oldsize: LongWord;
begin
  CheckReadOnly;

  oldsize := Size;
  Size := oldsize + sizebloc;
  FillMemory(FPtr + oldsize, sizebloc, fill);
end;

procedure TInternalTabFile.Delete(pos, sizebloc: LongWord);
begin
  CheckReadOnly;
  CheckBounds(pos);

  if (pos+sizebloc)>FSize then
     sizebloc := FSize-pos;

  if FSize>(pos+sizebloc) then
     MoveMemory(FPtr + pos, FPtr + pos + sizebloc, FSize - (pos+sizebloc));
  Size := FSize - sizebloc;
end;

function TTabStringsFile.Add(const S: string): LongWord;
var
  old: Longword;
  l: integer;
begin
  old := FSize;
  l := Length(s);
  if not FLastLineSeparator then
     inc(old, FLineSeparatorSize);
  Size := old + LongWord(l) + FLineSeparatorSize;

  if not FLastLineSeparator then
     CopyMemory(Fptr+old-FLineSeparatorSize, PChar(FLineSeparatorStr), FLineSeparatorSize);
  if l>0 then
     CopyMemory(Fptr+old, PChar(s), l);
  CopyMemory(Fptr+old+l, PChar(FLineSeparatorStr), FLineSeparatorSize);
  FLastLineSeparator := true;
  result := FLines.Add(Pointer(old));
end;

procedure TTabStringsFile.AddStrings(Strings: TStrings);
var
  i: integer;
begin
  for i:= 0 to Strings.Count-1 do
     Add(Strings[i]);
end;

procedure TTabStringsFile.AddStrings(Strings: ITabStringsFile);
var
  l: LongWord;
begin
  for l:= 0 to Strings.Count-1 do
     Add(Strings[l]);
end;

procedure TTabStringsFile.CheckTabBounds(index: Longword);
begin
  if index>=LongWord(FLines.Count) then
     raise ETabStringsFileError.CreateFmt('Indice %d hors limites', [index]);
end;

procedure TTabStringsFile.Clear;
begin
  FLines.Clear;
  FLastLineSeparator := true;
  Size := 0;
end;

constructor TTabStringsFile.CreateNew(fileName: TFileName;
 ls: TLineSeparator; bOverwrite: boolean);
begin
  inherited Create;
  CreateFile(fileName, 0, bOverwrite);
  Init;
  InitLignes;
  LineSeparator := ls;
end;

procedure TTabStringsFile.Delete(Index: DWord);
var
  pos, len: Longword;
  i: integer;
begin
  CheckTabBounds(index);
  GetLineInfosSep(index, pos, len);
  inherited Delete(pos, len);

  if integer(Index+1)=FLines.Count then
     FLastLineSeparator := true;
  FLines.Delete(index);

  for i:=index to LongWord(FLines.Count-1) do
     FLines.Items[i] := Pointer(LongWord(FLines.Items[i]) - len);
end;


destructor TTabStringsFile.Destroy;
begin
  FLines.Free;
  inherited;
end;

function TTabStringsFile.Equals(Strings: ITabStringsFile): Boolean;
var
  l, c: LongWord;
begin
  Result := False;
  c := GetCount;
  if c <> Strings.Count then
     exit;
  for l := 0 to c-1 do
     if Get(l) <> Strings.Get(l) then
        exit;
  result := True;
end;

procedure TTabStringsFile.Exchange(Index1, Index2: LongWord);
var
  tmp: string;
begin
  tmp := Get(Index1);
  Put(Index1, Get(Index2));
  Put(Index2, tmp);
end;

function TTabStringsFile.Get(Index: LongWord): string;
var
  pos, len: Longword;
begin
  CheckTabBounds(index);
  GetLineInfos(index, pos, len);
  SetString(Result, FPtr+pos, len);
end;

function TTabStringsFile.GetCount: LongWord;
begin
  result := FLines.Count;
end;

function TTabStringsFile.GetFileSize: LongWord;
begin
  result := FSize;
end;

procedure TTabStringsFile.GetLineInfos(index: Longword; var pos, len: Longword);
var
  i: Longword;
begin
  pos := Longword(FLines.items[Index]);
  if (Index+1)=LongWord(FLines.Count) then
  begin
     i := FSize;
     if FLastLineSeparator then
        dec(i, FLineSeparatorSize);
  end
  else
     i := Longword(FLines.items[integer(Index+1)]) - FLineSeparatorSize;
  len := i - pos;
end;

procedure TTabStringsFile.GetLineInfosSep(index: Longword; var pos,
 len: Longword);
begin
  pos := Longword(FLines.items[Index]);
  if integer(Index+1)=FLines.Count then
     len := FSize-pos
  else
     len := Longword(FLines.items[integer(Index+1)])-pos;
end;

function TTabStringsFile.GetText: PChar;
begin
  result := AllocMem(Size+1);
  MoveMemory(result, GetPtr, Size);
  result[size] := #0;
end;

function TTabStringsFile.GetTextStr: string;
begin
  SetString(Result, nil, Size);
  MoveMemory(@result[1], GetPtr, Size);
end;

function TTabStringsFile.IndexOf(const S: string): LongWord;
begin
  for Result := 0 to GetCount - 1 do
     if AnsiCompareText(Get(Result), S) = 0 then Exit;
  Result := $FFFFFFFF;
end;

procedure TTabStringsFile.Init;
begin
  FLines := TList.Create;
  LineSeparator := lsUndef;
end;

procedure TTabStringsFile.InitLignes;
var
  i, j: Longword;
begin
  FLines.Clear;

  if FSize<>0 then
  begin
     for i:=0 to FSize-1 do
     begin
        if FPtr[i]=#13 then
        begin
           LineSeparator := lsCR;
           if i+1<FSize then
              if FPtr[i+1]=#10 then
                 LineSeparator := lsCRLF;
           break;
        end;
        if FPtr[i]=#10 then
        begin
           LineSeparator := lsLF;
           break;
        end;
     end;
     if LineSeparator = lsUndef then
        LineSeparator := lsCRLF;

     FLastLineSeparator := false;

     i := 0;
     FLines.Add(Pointer(i));
     repeat
        j := 0;
        while (i+j<FSize) And (FLineSeparatorStr[j]<>#0) do
        begin
           if FPtr[i+j]<>FLineSeparatorStr[j] then
              break;
           inc(j);
        end;

        if FLineSeparatorStr[j]=#0 then
        begin
           inc(i, j);
           if i<FSize then
              FLines.Add(Pointer(i))
           else
              FLastLineSeparator := true;
        end
        else
           inc(i);
     until i >= FSize;
  end
  else
     FLastLineSeparator := true;

  if LineSeparator = lsUndef then
     LineSeparator := lsCRLF;
end;

procedure TTabStringsFile.Insert(Index: LongWord; const S: string);
var
  pos: LongWord;
  len: LongWord;
  i: longWord;
begin
  CheckReadOnly;

  if Index=LongWord(FLines.Count) then
     Add(s)
  else
  begin
     CheckBounds(index);

     len := Length(s);
     pos := LongWord(FLines.Items[index]);
     inherited Insert(pos, len + FLineSeparatorSize);

     MoveMemory(FPtr + pos, @s[1], len);
     MoveMemory(FPtr + pos + len, FLineSeparatorStr, FLineSeparatorSize);

     FLines.Insert(Index, Pointer(pos));

     for i:=index+1 to LongWord(FLines.Count-1) do
        FLines.Items[i] := Pointer(LongWord(FLines.Items[i]) + len + FLineSeparatorSize);
  end;
end;

procedure TTabStringsFile.LoadFromFile(const FileName: string);
var
  str: TFileStream;
begin
  str := TFileStream.Create(FileName, fmOpenRead);
  try
     LoadFromStream(str);
  finally
     str.Free;
  end;
end;

procedure TTabStringsFile.LoadFromStream(Stream: TStream);
var
  offset: integer;
  n: integer;
const
  blocsize = 4096;
begin
  offset := 0;
  Size := 0;
  repeat
     Size := Size + blocsize;
     n := Stream.Read((FPtr+offset)^, blocsize);
     inc(offset, n);
  until n<>blocsize;
  Size := offset;
  InitLignes;
end;

procedure TTabStringsFile.Move(CurIndex, NewIndex: LongWord);
var
  tmp: string;
begin
  if CurIndex <> NewIndex then
  begin
     tmp := Get(CurIndex);
     Delete(CurIndex);
     Insert(NewIndex, tmp);
  end;
end;

function TTabStringsFile.OffsetIndex(offset: LongWord): LongWord;
var
  low, high: LongWord;
  i: Longword;
  inddeb, indfin: Longword;
begin
  Result := $FFFFFFFF;
  low := 0;
  high := FLines.Count-1;

  while low <= high do
  begin
     i := low + ((high - low) shr 1);

     inddeb := Longword(FLines.items[i]);
     if (i+1)=LongWord(FLines.Count) then
        indfin := FSize
     else
        indfin := Longword(FLines.items[integer(i+1)]);


     if offset < inddeb then
        high := i-1
     else if offset >= indfin then
        low := i+1
     else
     begin
        Result := i;
        break;
     end;
  end;
end;

constructor TTabStringsFile.Open(fileName: TFileName;
 accessMode: TAccessMode);
begin
  inherited Create;
  OpenFile(fileName, accessMode);
  Init;
  InitLignes;
end;

procedure TTabStringsFile.Put(Index: LongWord; const S: string);
var
  pos, len: Longword;
  l: Longword;
  p: Longword;
  off, i: integer;
begin
  CheckTabBounds(index);
  GetLineInfos(index, pos, len);

  l := Length(s);
  p := LongWord(FLines.Items[index]);

  off := integer(l)-integer(len);

  if off>0 then
     Inherited Insert(p, l-len)
  else if off<0 then
     Inherited Delete(p, len-l);
  MoveMemory(FPtr + p, @s[1], l);

  for i:=index+1 to LongWord(FLines.Count-1) do
     FLines.Items[i] := Pointer(Integer(FLines.Items[i]) + off);
end;

procedure TTabStringsFile.SaveToFile(const FileName: string);
var
  f: TFileStream;
begin
  f := TFileStream.Create(FileName, fmOpenWrite);
  try
     SaveToStream(f);
  finally
     f.Free;
  end;
end;

procedure TTabStringsFile.SaveToStream(Stream: TStream);
const
  blocsize=4096;
var
  i: longword;
begin
  i := 0;
  while Stream.Write(FPtr[i], blocsize)=blocsize do
     inc(i, blocsize);
end;

function TTabStringsFile.Search(const S: string; Index: LongWord=0): LongWord;
var
  bms: IBMSearch;
  pos: LongWord;
begin
  CheckBounds(index);
  if Length(s)=0 then
  begin
     Result := $FFFFFFFF;
     exit;
  end;

  bms:= TBMSearch.Create(s);
  Result := bms.Search(FPtr, Size, Longword(FLines.items[Index]));
  if Result<>$FFFFFFFF then
  begin
     result := OffsetIndex(Result);
  end;
end;

procedure TTabStringsFile.SetLineSeparator(const Value: TLineSeparator);
begin
  FLineSeparator := Value;
  case FLineSeparator of
     lsUndef: FLineSeparatorStr := '';
     lsCR:    FLineSeparatorStr := #13;
     lsLF:    FLineSeparatorStr := #10;
     lsCRLF:  FLineSeparatorStr := #13#10;
  end;
  FLineSeparatorSize := StrLen(FLineSeparatorStr);
end;

procedure TTabStringsFile.SetText(Text: PChar);
begin
  Size := StrLen(Text);
  MoveMemory(FPtr, text, FSize);
  InitLignes;
end;

procedure TTabStringsFile.SetTextStr(const Value: string);
begin
  SetText(PChar(Value));
end;

function TTabFile.Offset(off: longWord): pointer;
begin
  result := FPtr + off;
end;

end.
Cevapla
#2
Listview'in ondata kısmına bu kodu yazınca çalışıyor. peki listview kullanmadan bu degeri nasıl stringe aktarabilirim.

Item.SubItems.Add(FTab[Item.Index]);



Ondata kısmında çalışıyor

item:= ListView1.Items.Add;
  item.Caption := IntToStr(Item.Index);
 Item.SubItems.Add(FTab[Item.Index]);
// stringe aktarmak istiyorum
Cevapla
#3
(12-07-2017, Saat: 18:06)Delphiseven Adlı Kullanıcıdan Alıntı: Linkleri Görebilmeniz İçin Giriş yap veya Üye OlListview'in ondata kısmına bu kodu yazınca çalışıyor. peki listview kullanmadan bu degeri nasıl stringe aktarabilirim.

Item.SubItems.Add(FTab[Item.Index]);



Ondata kısmında çalışıyor

item:= ListView1.Items.Add;
  item.Caption := IntToStr(Item.Index);
 Item.SubItems.Add(FTab[Item.Index]);
// stringe aktarmak istiyorum
var
a:string;
begin
a:=FTab[Item.Index];
end;
Linkleri Görebilmeniz İçin Giriş yap veya Üye Ol
WWW
Cevapla

Konuyu Paylaş : facebook gplus twitter



Konu ile Alakalı Benzer Konular
Konular Yazar Yorumlar Okunma Son Yorum
  Başlık ekleme Dostk 2 159 01-02-2018, Saat: 14:23
Son Yorum: Abdullah ILGAZ
  Webbrowser form element item adları bkantur 3 108 16-12-2017, Saat: 22:30
Son Yorum: SimaWB
Smile Bileşenden bileşen türetme veya özellik ekleme Lord_Ares 3 322 11-12-2017, Saat: 13:40
Son Yorum: mad85
  Listview içinde arada dilo 4 121 06-12-2017, Saat: 09:09
Son Yorum: Fesih ARSLAN
Question Uzak Bir Bilgisayar İçin Port Ekleme? hyperxman 21 822 22-11-2017, Saat: 00:03
Son Yorum: nguzeller



Konuyu Okuyanlar: 1 Ziyaretçi