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











SourceForge.net Logo

SourceForge.net Logo

GitHub Logo

Discord 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?