🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #2421

Re: Dragging from TEdit

#2421
From: DreamChaser
Date: Thu, 01 Mar 2007 22:41
62 lines
3030 bytes
Jos� wrote:
>> It looks like you will need to set the drag manually. In the MouseDown 
>> of the Edit1 set the drag mode to true, in the MouseOver of Edit2 allow 
>> accepting, and in the DragDrop (I think) of Edit 2 do your data 
>> manipulation.
> 
> The compiler complains if I set DragMode to a Boolean. Besides, it
> makes it impossible to edit data. But worse, your suggestion seems to
> imply that the program must know in advance whether the user intends
> to drag from Edit1 to Edit2 or the other way around.

 From BCB Help Files:
void __fastcallTFMForm::FileListBox1MouseDown(TObject *Sender,
   TMouseButton Button, TShiftState Shift, int X, int Y)
{
   if (Button == mbLeft)	// drag only if left button pressed
   {
     TFileListBox *pLB = (TFileListBox *)Sender; // cast to TFileListBox
     if(pLB->ItemAtPos(Point(X,Y), true) >= 0) // is there an item here?
       pLB->BeginDrag(false);                   // if so, drag it
   }
}

void __fastcallTForm1::TreeView1DragOver(TObject *Sender, TObject *Source,

   int X, int Y, TDragState State, bool &Accept)
{
   if (Source->InheritsFrom(__classid(TFileListBox)))
     Accept = true;
}

void __fastcall TForm1::TreeView1DragDrop(TObject *Sender, TObject *Source,
int X, int Y){

   if (Source->InheritsFrom(__classid(TFileListBox)))
   {
     TTreeNode *pNode = TreeView1->GetNodeAt(X,Y); // pNode is drop target
     AnsiString NewFile = pNode->Text + AnsiString("/") +
       ExtractFileName(FileList->FileName); // build file name for drop 
target
     MoveFileEx(FileList->FileName.c_str(), NewFile.c_str(),
       MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED); // move the file
   }
}


What does all this mean:

Edit1OnMouseDown
	Edit1->BeginDrag(true);

Edit2DragOver
	if (Source == Edit2) { Accept = true; }

Edit2DragDrop
	Edit2->Text = Edit1->Text;

There are things about the mouse cursor that you also need to do 
manually but I'm unable to remember all at this time. But look up 
drag-drop operations in the Help files.

DC
Technical Details
Message-ID: <45e7568d@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <25fbu2tag6s8t0mseuqqh5qd87r8cppdus@4ax.com> <45e624ed$1@newsgroups.borland.com> <ui6du2d4vqgcebqbc44pbr4m3g11etujjh@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,fc5357fd4c67f7bd
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII
Date: Thu, 01 Mar 2007 16:41:26 -0600
From: DreamChaser <jkofsky@No-Spam.net>
User-Agent: Thunderbird 1.5.0.9 (Windows/20061207)
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Dragging from TEdit
References: <25fbu2tag6s8t0mseuqqh5qd87r8cppdus@4ax.com> <45e624ed$1@newsgroups.borland.com> <ui6du2d4vqgcebqbc44pbr4m3g11etujjh@4ax.com>
In-Reply-To: <ui6du2d4vqgcebqbc44pbr4m3g11etujjh@4ax.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
NNTP-Posting-Host: 74.242.135.205
Message-ID: <45e7568d@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1172788877 74.242.135.205 (1 Mar 2007 14:41:17 -0800)
Lines: 62
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail