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?
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 previous 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
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Tranparent TopWindow
Next Topic: Bug: TopMost blocks Prompt dialog
Goto Forum:
  


Current Time: Mon Jun 10 19:26:47 CEST 2024

Total time taken to generate the page: 0.01131 seconds