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












SourceForge.net Logo
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 Go to next message
nixnixnix is currently offline  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 Go to previous messageGo to next message
mrjt is currently offline  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();
}

Smile
Re: Howto Drop Files into a TopWindow please? [message #13933 is a reply to message #13908] Fri, 01 February 2008 22:47 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Nice one, I have adapted it for reference.

Mirek
Re: Howto Drop Files into a TopWindow please? [message #20324 is a reply to message #13908] Tue, 10 March 2009 21:28 Go to previous message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
Thanks, I feel terrible that I never checked back but I appreciate it now Smile
Previous Topic: Tranparent TopWindow
Next Topic: Bug: TopMost blocks Prompt dialog
Goto Forum:
  


Current Time: Thu Mar 28 17:01:18 CET 2024

Total time taken to generate the page: 0.01499 seconds