Home » U++ Library support » TopWindow&PopUp, TrayIcon » Howto Drop Files into a TopWindow please?
Howto Drop Files into a TopWindow please? [message #13844] |
Tue, 29 January 2008 21:20 |
nixnixnix
Messages: 415 Registered: February 2007 Location: Kelowna, British Columbia
|
Senior Member |
|
|
Hi there,
I know that DnD is new last year but there is no documentation on it and I really don't understand how it is supposed to work from just looking at the code.
Could we perhaps have an example of how to drop a bunch of files into a Ctrl or TopWindow and to then retrieve their paths as Strings. I have tried to implement this for my app but I don't appear to have any events to callback from and I get a big no entry cursor when dragging files from explorer over the TopWindow.
Nick
EDIT: ah ok I think I get it. Drag and Drop is only available to and from the same type of control right? So dropping in files from out side the app would not be supported just yet correct?
[Updated on: Wed, 30 January 2008 15:06] Report message to a moderator
|
|
|
Re: Howto Drop Files into a TopWindow please? [message #13908 is a reply to message #13844] |
Fri, 01 February 2008 11:38 |
mrjt
Messages: 705 Registered: March 2007 Location: London
|
Contributor |
|
|
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
class DndTest : public TopWindow {
public:
typedef DndTest CLASSNAME;
DndTest();
Vector<String> files;
virtual void Paint(Draw &w);
void TextLine(Draw &w, Point &p, const String &txt);
virtual void DragAndDrop(Point p, PasteClip& d);
};
void DndTest::Paint(Draw &w)
{
TopWindow::Paint(w);
Point p(2, 2);
TextLine(w, p, "Files:");
if (files.GetCount())
for (int i = 0; i < files.GetCount(); i++)
TextLine(w, p, files[i]);
else
TextLine(w, p, "None");
}
void DndTest::TextLine(Draw &w, Point &p, const String &txt)
{
w.DrawText(p.x, p.y, txt);
p.y += StdFont().GetHeight()+1;
}
// This is the important bit:
void DndTest::DragAndDrop(Point p, PasteClip& d)
{
if (AcceptFiles(d)) {
files = GetFiles(d);
Refresh();
}
}
DndTest::DndTest()
{
Title("I need files!");
SetRect(0, 0, 200, 400);
CenterScreen();
}
GUI_APP_MAIN
{
DndTest().Run();
}
|
|
|
|
|
Goto Forum:
Current Time: Fri Sep 20 05:35:55 CEST 2024
Total time taken to generate the page: 0.02980 seconds
|