don't clear cell if containing picture (bmp)

General TRichView support forum. Please post your questions here
Post Reply
j&b
Posts: 182
Joined: Mon Sep 05, 2005 1:35 pm

don't clear cell if containing picture (bmp)

Post by j&b »

Hello,

first thanks to Sergey for his last answere (fix memo-table-cell-border-lines).

Now I want to clear (and center) memo-table.cells if they are empty or contain a 'x'.
Until I don't put a picture (vertical script as bmp) all okay (see below).
How can I prevent that in this case (cell contains a bmp-picture) cell is cleared?

Jürgen


for r := 0 to rveTable.Rows.Count-1 do begin
for c:=4 to 6 do begin

s:='';
if rveTable.Cells[r,c]<>nil then begin
rveTable.EditCell(r,c);
s:=ansiLowerCase(memo.TopLevelEditor.GetCurrentItemText);

if (s='') or (s='x') then begin
//s='' if cell contains a picture (bmp) <------------------
// in this case cell shall not be cleared <------------------
// How can I prevent that in this case cell is cleared?
rveTable.Cells[r,c].Clear; //löscht, aber zentriert nicht
rveTable.Cells[r,c].AddNL('',0,1); //damit zentriert
end; //if (s='') or

end; //if rveTable.Cells[r,c]
end; //for c:=4 to 6 do begin
end; //for r := 0 to rveTable.Rows.Count-1
j&b
Posts: 182
Joined: Mon Sep 05, 2005 1:35 pm

Post by j&b »

I have added one line (...GetPictureInfo(memo.TopLevelEditor.CurItemNo...):

if rveTable.Cells[r,c]<>nil then begin
rveTable.EditCell(r,c);
s:=ansiLowerCase(memo.TopLevelEditor.GetCurrentItemText);
if (s='') or (s='x') then begin

memo.TopLevelEditor.GetPictureInfo(memo.TopLevelEditor.CurItemNo,pname,pimg,palign,ptag);

rveTable.Cells[r,c].Clear;
rveTable.Cells[r,c].AddNL('',0,1);
end;
end;


Program stops in CRVData.pas (I have set a stop at the line below ...GetPictureInfo... )

procedure TCustomRVData.CheckItemClass(ItemNo: Integer; RequiredClass: TCustomRVItemInfoClass);
begin
if not (Items.Objects[ItemNo] is RequiredClass) then
raise ERichViewError.Create(errRVTypesMismatch);
end;

Can someone (?Sergey?) help me ?

Jürgen
Sergey Tkachenko
Site Admin
Posts: 17310
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

GetPictureInfo can be called only for picture items. An exception occurs if this method is called for other types or items, such as text.
Type of item can be checked using GetItemStyle method. For text, it's zero or positive value. For picture, it is rvsPicture constant (negative).
Also, it's not necessary to initialize editing for cells, it slows down the execution a lot.

Code: Select all

for r := 0 to rveTable.Rows.Count-1 do begin 
  for c:=4 to 6 do begin 

    s:=''; 
    if rveTable.Cells[r,c]<>nil then begin 
      s:=ansiLowerCase(rveTable.Cells[r,c].GetRVData.GetItemTextA(0)); 
      if (rveTable.Cells[r,c].GetRVData.GetItemStyle(0)>=0) and
         ((s='') or (s='x')) then begin 
        rveTable.Cells[r,c].GetRVData.Clear; //löscht, aber zentriert nicht 
        rveTable.Cells[r,c].GetRVData.AddNL('',0,1); //damit zentriert 
      end; //if
    end; //if rveTable.Cells[r,c] 
  end; //for c:=4 to 6 do begin 
end; //for r := 0 to rveTable.Rows.Count-1
j&b
Posts: 182
Joined: Mon Sep 05, 2005 1:35 pm

don't clear cell if containing picture (bmp)

Post by j&b »

Thank you, Sergey

Jürgen
Post Reply