Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site











SourceForge.net Logo

DragAndDropImg

 

Example of basic DnD API

 

 

main.cpp

 

#include <CtrlLib/CtrlLib.h>

 

using namespace Upp;

 

struct MyApp : TopWindow {

    virtual void CancelMode();

    virtual void Paint(Draw& w);

    virtual void DragAndDrop(Point p, PasteClip& d);

    virtual void DragLeave();

 

    Image img;

    bool  dnd;

    

    MyApp() { dnd = false; }

};

 

void MyApp::Paint(Draw& w)

{

    Size sz = GetSize();

    w.DrawRect(sz, dnd ? SColorInfo() : SColorFace());

    w.DrawImage(0, 0, img);

}

 

void MyApp::DragAndDrop(Point p, PasteClip& d)

{

    if(AcceptImage(d))

        img = GetImage(d);

    dnd = d.IsAccepted();

    Refresh();

}

 

void MyApp::DragLeave()

{

    CancelMode();

}

 

void MyApp::CancelMode()

{

    dnd = false;

    Refresh();

}

 

GUI_APP_MAIN

{

    MyApp().Run();

}

 

 

 

 

Do you want to contribute?