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












SourceForge.net Logo



Home » U++ Library support » Archive » drag & drop
drag & drop [message #650] Mon, 23 January 2006 20:58 Go to next message
hojtsy is currently offline  hojtsy
Messages: 239
Registered: January 2006
Location: Budapest, Hungary
Experienced Member
Is it possible to accept files/links/text drag & dropped from an other application? It seems that I can not even drag&drop text from one text input into an other one inside the same app. If these are not yet possible, could we add them to the wishlist?
Thanks
Re: drag & drop [message #651 is a reply to message #650] Mon, 23 January 2006 21:06 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 10924
Registered: November 2005
Ultimate Member
Well, this is one of things that is still missing in U++. Means you can implement drag&drop in U++, including dropping files from other apps etc... but there is no direct support for doing so.

It is already on ToDo list.

Partial problem here is that solution should involve both X11 and OLE mechanisms, or at least be flexible enough to allow them later.
Re: drag & drop [message #8119 is a reply to message #651] Sun, 11 February 2007 00:46 Go to previous messageGo to next message
mobilehunter is currently offline  mobilehunter
Messages: 87
Registered: November 2006
Member
just testing with codes pieces from TCtrllib directrory.
drag qtf file and the richeditor will open it.
#include <CtrlLib/CtrlLib.h>
#include <RichEdit/RichEdit.h>
#include <shellapi.h>
using namespace Upp;

#define LAYOUTFILE "MainLay.lay"
#include <CtrlCore/lay.h>
/*
DragAcceptFiles
DragFinish
DragQueryFile
DragQueryPoint
*/

class TestDragDrop : public WithMainGUI<TopWindow>
{
	public:
		TestDragDrop();
		~TestDragDrop();	
		virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
	
	private:
		void showDroppedFiles(HDROP dropInfo);
	private:
		RichEdit editor;
		typedef TestDragDrop CLASSNAME;
};

TestDragDrop::TestDragDrop()
{
	Add(editor.SizePos());
	editor.SetFocus();
	Open();
	HWND hwnd = GetHWND();
	DragAcceptFiles(hwnd,true);
}

TestDragDrop::~TestDragDrop()
{
}

void TestDragDrop::showDroppedFiles(HDROP hdrop)
{
	//get how many are dropped
	int count = DragQueryFile((HDROP)hdrop, (DWORD)-1, 0, 0);
	Vector<String> list;
	for(int i = 0; i < count; i++) {
		//get length of files name
		int length = DragQueryFile((HDROP)hdrop, i, 0, 0);
		String s;
		DragQueryFile((HDROP)hdrop, i, s.GetBuffer(length), length + 1);
		s.ReleaseBuffer(length);
		//Taken from UWord codes
		editor.SetQTF(LoadFile(s));
		editor.ClearModify();
	}
	DragFinish((HDROP)hdrop);
}

LRESULT TestDragDrop::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
	HWND hwnd = GetHWND();
	switch(message) 
	{
		case WM_DROPFILES:
		{
			showDroppedFiles((HDROP)wParam);
			return 0;
		}
		default:
			return TopWindow::WindowProc(message, wParam, lParam);
	}
	return true;
}

GUI_APP_MAIN
{
	TestDragDrop test;
	
	test.Run();
}


Re: drag & drop [message #8122 is a reply to message #8119] Sun, 11 February 2007 09:47 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 10924
Registered: November 2005
Ultimate Member
Thanks. Really not that complicated, is it? (What IS complicated is to support all variants, including OLE D&D, in-application D&D, X11 D&D etc....)

BTW, according to "U++ programming paradigm", I do not quite like this part:

mobilehunter wrote on Sat, 10 February 2007 18:46

just testing with codes pieces from TCtrllib directrory.
drag qtf file and the richeditor will open it.
TestDragDrop::TestDragDrop()
{
	Add(editor.SizePos());
	editor.SetFocus();
	Open();
	HWND hwnd = GetHWND();
	DragAcceptFiles(hwnd,true);
}




Opening dialog in constructor is "bad practice" (of course, it works as expected and in experimental code it is OK).

Anyway, notice quite useful methods in Ctrl::

	virtual void    NcCreate(HWND hwnd);
	virtual void    NcDestroy();
	virtual void    PreDestroy();


Mirek
Re: drag & drop [message #8138 is a reply to message #8122] Mon, 12 February 2007 07:12 Go to previous message
mobilehunter is currently offline  mobilehunter
Messages: 87
Registered: November 2006
Member
I removed the Open and the rest from constructor.
And add this codes.
So i have to put codes that need immediate access to hwnd inside NcCreate, right?

void TestDragDrop::NcCreate(HWND hwnd)
{
	Ctrl::NcCreate(hwnd);
	DragAcceptFiles(hwnd,true);
}


Thanks for the correction.
Previous Topic: How to try classes inside TCtrlLib?
Goto Forum:
  


Current Time: Sun Feb 26 18:21:46 CET 2017

Total time taken to generate the page: 0.00398 seconds