Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / CONFUSSED WITH DnD

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. CONFUSSED WITH DnD
#3473
Posted by: 2004-03-08 04:59:54
I can't get drag and drop to work with my program.
First off, how do I accossiate data for wxDropTarget?  I have been trying to put
wxFileDataObject
as the first paramater for the wxDropTarget;  however, when I try to use use the wxDropTarget in SetDropTarget, Dev-C++ gives me an error that says there is no matching function for call to ' MainFrame::SetDropTarget( wxDropTarget*(&)(wxFileDataObject (*)()))'

Thanks, any help will be immensly appreciated
Message2. Re: CONFUSSED WITH DnD
#4490
Posted by: str3l0k 2004-06-16 21:05:36
You need to derrive you class from wxDropTarget... There you need to override
some functions: OnData, OnDrop...
...MyDropTarget : public wxDropTarget...

then you need to make you window, able to receive drops on it...
i do this just after i create a window:

MyDropTarget * dropTarget = new MyDropTarget(this);  //this - as parent
dropTarget->SetDataObject(new wxFileDataObject());   //sets what format will our dropTarget like.
myDnDTargetWindow->SetDropTarget(dropTarget); //Enable droping objects on this window...
Now in MyDropTarget::OnData you can do whatever you want with the data received...

If you want to drag something you need to create a DropSource

    wxFileDataObject my_data(&data); //The object being dragged
    //init the my_data here with the values you want to drag...
    CDropSource dragSource( this ); //create drop source
    dragSource.SetData( my_data ); //set the data being draged to the source
    dragSource.DoDragDrop( TRUE ); //start dragging...

Please note that this code might not be very correct... It's just what i came up to for my project :) Also take a look at DnD sample from wxWidgets samples.

It's a little too much in that sample, but you can still learn from it...
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
¥1,800.00 ·
 
 
¥489.00 ·
 
 
¥288.00 ·
 
 
¥908.00 ·
 
 
¥748.00 ·
 
 
¥264.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0