#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(); }
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); } |
virtual void NcCreate(HWND hwnd); virtual void NcDestroy(); virtual void PreDestroy();
void TestDragDrop::NcCreate(HWND hwnd) { Ctrl::NcCreate(hwnd); DragAcceptFiles(hwnd,true); }