trichview.com

trichview.support




Re: How to dragdrop from a TreeView??


Return to index


Author

Message

Sergey Tkachenko

Posted: 10/13/2004 19:29:29


Add after

Customrve->GetSelectionBounds(StartNo, StartOffs, EndNo, EndOffs, true):


  if (StartNo<0)

    return; // no selection



>

> I'd like to dragdrop the text of a selected TreeNode to the RichViewEdit.

>

> I've got the following code:

>

> void __fastcall TForm1::rveDragOver(TObject *Sender, TObject *Source,

>       int X, int Y, TDragState State, bool &Accept)

> {

>   Accept = Source->ClassNameIs("TTreeView");

> }

>

//--------------------------------------------------------------------------

-

>

> void __fastcall TForm1::rveDragDrop(TObject *Sender, TObject *Source,

>       int X, int Y)

> {

>   if(Sender->ClassNameIs("TRichViewEdit") &&

Source->ClassNameIs("TTreeView"))

>   {

>     AnsiString aURL = ((TTreeView *)Source)->Selected->Text;

>

>     int StartNo, EndNo, StartOffs, EndOffs;

>     TCustomRichViewEdit *Customrve = rve->TopLevelEditor;

>     Customrve->GetSelectionBounds(StartNo, StartOffs, EndNo, EndOffs,

true);

>     if(StartOffs >= Customrve->GetOffsAfterItem(StartNo)) StartNo++;

>     if(EndOffs <= Customrve->GetOffsBeforeItem(EndNo)) EndNo--;

>     Customrve->BeginUndoGroup(rvutTag);

>     Customrve->SetUndoGroupMode(true);

>     for(int i=StartNo; i<=EndNo; i++)

>     Customrve->SetItemTagEd(i, (int)StrNew(aURL.c_str()));

>     Customrve->SetUndoGroupMode(false);

>   }

> }

>

//--------------------------------------------------------------------------

-

>

> The problem is that it doesn't work. I get the following error message:

'List

> index out of bounds(-1)'

>

> I can't find the problem...

>

> Could you help me?

>

> Thanks.

>

> Pieter E.





Powered by ABC Amber Outlook Express Converter