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 » Archive » drag & drop
Re: drag & drop [message #8119 is a reply to message #651] Sun, 11 February 2007 00:46 Go to previous messageGo to previous 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();
}


 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to try classes inside TCtrlLib?
Goto Forum:
  


Current Time: Wed Apr 24 13:00:28 CEST 2024

Total time taken to generate the page: 0.03434 seconds