trichview.com

trichview.support




Re: Deleting Field with "rvprDeleteProtect"


Return to index


Author

Message

Sergey Tkachenko

Posted: 05/13/2005 22:47:52


First, you need to find and selet this field.

Then remove rvprDeleteProtect.

Then call DeleteSelection.

Then restore rvprDeleteProtect.


The procedure for finding and selection can be similar to recursive

procedure of calculating field counts.

But in this message I'll make in in the different way - using the method

RVData.EnumItems.

This method call the specified procedure one time for each item in the

document.


It has two user-defined parameters.

We will use UserData1 to pass the result (index of text style of the found

field).

We will use UserData2 to store the field code to delete.


procedure TForm1.EnumAndSelectFields(RVData: TCustomRVData;

  ItemNo: Integer; var UserData1: Integer; const UserData2: String;

  var ContinueEnum: Boolean);

var StyleNo: Integer;

begin

  StyleNo := RVData.GetItemStyle(ItemNo);

  if (StyleNo>=0) and

     (rvprModifyProtect in RVStyle1.TextStyles[StyleNo].Protection) and

     (PChar(RVData.GetItemTag(ItemNo))=UserData2) then begin

    RVData := RVData.Edit;

    TCustomRVFormattedData(RVData).SetSelectionBounds(

      ItemNo, RVData.GetOffsBeforeItem(ItemNo),

      ItemNo, RVData.GetOffsAfterItem(ItemNo));

    UserData1 := StyleNo;

    ContinueEnum := False;

    end

  else

    ContinueEnum := True;

end;


Now, how to use this procedure:


procedure TForm1.Button3Click(Sender: TObject);

var Res: Integer;

    WasProtected: Boolean;

begin

  Res := -1;

  rve.RVData.EnumItems(EnumAndSelectFields, Res, Edit1.Text);

  if Res<0 then

    exit;

  WasProtected := rvprDeleteProtect in RVStyle1.TextStyles[Res].Protection;

  RVStyle1.TextStyles[Res].Protection :=

RVStyle1.TextStyles[Res].Protection-[rvprDeleteProtect];

  rve.DeleteSelection;

  if WasProtected then

    RVStyle1.TextStyles[Res].Protection :=

RVStyle1.TextStyles[Res].Protection-[rvprDeleteProtect];

end;



>

> Hi

> I use DBRichViewEdit.

> some fields exist that are inserted with Protection:

>

> [rvprStyleProtect,

> rvprModifyProtect,

> rvprDeleteProtect,

> rvprConcateProtect,

> rvprDoNotAutoSwitch]

>

> In a Panel1 I have: Edit1 and button "Delete".

> In the Edit1 the user indicate the name of the field that it would like to

> delete.

> how to locate the field that the user typed and to deleted having the

protection[rvprDeleteProtect]?

>

>

> thanks

> Diogo

>





Powered by ABC Amber Outlook Express Converter