get.cell.font.size (2)
Posted: Sat May 26, 2007 2:06 pm
Hello Sergey,
your solution runs fine.
Now I tried it at another position in programm (if someone presses key "1" (number one) program shall write "Paul" in the cell, if someone press the 2, code shall write something oher in the the 3. cell), but I always get an error. The last try shows an eAcessViolation-hint.
It must be be a very,very small mistake. Can you eliminate him ? (I hope so)
procedure TForm1.memoKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
var r,c,cs,rs,ItemNo,Data,Offs, styleNo,paraNo: Integer;
begin
if (ssCtrl in Shift) then begin
…
end else begin
if { (not memo.CanChange) or } (not memo.GetCurrentItemEx(TRVTableItemInfo, rve, TCustomRVItemInfo(rveTable))) then exit;
if (key>48) and (key<57) then begin
if key=49 then s:= fverbBeno[1] else if key=50 then s:= fverbBeno[2] else if key=51 then s:= fverbBeno[3]
else if key=52 then s:= fverbBeno[4] else if key=53 then s:= fverbBeno[5] else if key=54 then s:= fverbBeno[6]
else if key=55 then s:= fverbBeno[7] else if key=56 then s:= fverbBeno[8];
memo.GetCurrentItemEx(TRVTableItemInfo, rve, TCustomRVItemInfo(rveTable));
ItemNo := memo.GetItemNo(rveTable);
memo.BeginItemModify(ItemNo, Data);
rveTable.GetSelectionBounds(r,c,i,j); // akt. Row + Col
if (rveTable.colCount=3) and (c=2) then begin
if (rveTable.Cells[r,2]<>nil) and (rveTable.Cells[r,2].GetRVData.GetItemStyle(0)>=0) then begin
styleNo := rveTable.Cells[r,2].GetRVData.GetItemStyle(0);
ParaNo := rveTable.Cells[r,2].GetRVData.GetItemPara(0);
rveTable.Cells[r,2].clear;
rveTable.Cells[r,2].AddNL(s,StyleNo,ParaNo);
end;
//if rveTable<>nil then begin
memo.EndItemModify(ItemNo, Data);
memo.Change;
//end;
if table1.state in [dsEdit, dsInsert] then table1.post;
ShowMessage(intToStr(r)+' '+intToStr(c)); //After showing row + col program shows an error-message (EAccessViolation)
end;
end;
end;
procedure TForm1.memoChange(Sender: TObject);
begin
if fModified=false then begin
pPostenSch.enabled:=true; pPostenBem.enabled:=true; pPosten.Visible:=true;
fModified:=true; //zum Steuern von pPosten - pPosten = aktiv
end;
lAktZmemo.Caption:=intToStr(memoZeile);
lAnzZmemo.Caption:=intToStr(HowManyLines(memo));
memo.Reformat; // keeps the selection (and caret position )
if memo.InplaceEditor<>nil then memo.InplaceEditor.Invalidate;
end;
your solution runs fine.
Now I tried it at another position in programm (if someone presses key "1" (number one) program shall write "Paul" in the cell, if someone press the 2, code shall write something oher in the the 3. cell), but I always get an error. The last try shows an eAcessViolation-hint.
It must be be a very,very small mistake. Can you eliminate him ? (I hope so)
procedure TForm1.memoKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
var r,c,cs,rs,ItemNo,Data,Offs, styleNo,paraNo: Integer;
begin
if (ssCtrl in Shift) then begin
…
end else begin
if { (not memo.CanChange) or } (not memo.GetCurrentItemEx(TRVTableItemInfo, rve, TCustomRVItemInfo(rveTable))) then exit;
if (key>48) and (key<57) then begin
if key=49 then s:= fverbBeno[1] else if key=50 then s:= fverbBeno[2] else if key=51 then s:= fverbBeno[3]
else if key=52 then s:= fverbBeno[4] else if key=53 then s:= fverbBeno[5] else if key=54 then s:= fverbBeno[6]
else if key=55 then s:= fverbBeno[7] else if key=56 then s:= fverbBeno[8];
memo.GetCurrentItemEx(TRVTableItemInfo, rve, TCustomRVItemInfo(rveTable));
ItemNo := memo.GetItemNo(rveTable);
memo.BeginItemModify(ItemNo, Data);
rveTable.GetSelectionBounds(r,c,i,j); // akt. Row + Col
if (rveTable.colCount=3) and (c=2) then begin
if (rveTable.Cells[r,2]<>nil) and (rveTable.Cells[r,2].GetRVData.GetItemStyle(0)>=0) then begin
styleNo := rveTable.Cells[r,2].GetRVData.GetItemStyle(0);
ParaNo := rveTable.Cells[r,2].GetRVData.GetItemPara(0);
rveTable.Cells[r,2].clear;
rveTable.Cells[r,2].AddNL(s,StyleNo,ParaNo);
end;
//if rveTable<>nil then begin
memo.EndItemModify(ItemNo, Data);
memo.Change;
//end;
if table1.state in [dsEdit, dsInsert] then table1.post;
ShowMessage(intToStr(r)+' '+intToStr(c)); //After showing row + col program shows an error-message (EAccessViolation)
end;
end;
end;
procedure TForm1.memoChange(Sender: TObject);
begin
if fModified=false then begin
pPostenSch.enabled:=true; pPostenBem.enabled:=true; pPosten.Visible:=true;
fModified:=true; //zum Steuern von pPosten - pPosten = aktiv
end;
lAktZmemo.Caption:=intToStr(memoZeile);
lAnzZmemo.Caption:=intToStr(HowManyLines(memo));
memo.Reformat; // keeps the selection (and caret position )
if memo.InplaceEditor<>nil then memo.InplaceEditor.Invalidate;
end;