Home » U++ Library support » U++ Library : Other (not classified elsewhere) » Image DnD into Upp app
Image DnD into Upp app [message #44168] |
Wed, 14 January 2015 15:28 |
|
bushman
Messages: 134 Registered: February 2009
|
Experienced Member |
|
|
Hi, there!
I need to drag an image file from a Windows non-Upp app (say, File Explorer, for one) and drop/show it on a StaticImage Ctrl. Is there a Upp way of doing this? How, pls?
tks!
[Updated on: Wed, 14 January 2015 15:40] Report message to a moderator
|
|
|
|
Re: Image DnD into Upp app [message #44170 is a reply to message #44169] |
Wed, 14 January 2015 22:09 |
|
bushman
Messages: 134 Registered: February 2009
|
Experienced Member |
|
|
Thank you for the code, Mirek, but I'm afraid it doesn't work. BTW, before I posted this topic I've tried something quite close to what you suggest, based on what I could learn from the IDE help and reference code, but it failed too.
I've inserted some LOGs in your code to see if any of the DnD-related virtual methods ever get called, which they don't, with the exception of CancelMode(), but obviously for other non-DnD reasons:
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
struct MyApp : TopWindow {
virtual void CancelMode();
virtual void Paint(Draw& w);
virtual void DragAndDrop(Point p, PasteClip& d);
virtual void DragLeave();
Image img;
bool dnd;
MyApp() { dnd = false; }
};
void MyApp::Paint(Draw& w)
{
Size sz = GetSize();
w.DrawRect(sz, dnd ? SColorInfo() : SColorFace());
w.DrawImage(0, 0, img);
}
void MyApp::DragAndDrop(Point p, PasteClip& d)
{
LOG("DragAndDrop"); // this never gets called
if(AcceptImage(d))
img = GetImage(d);
dnd = d.IsAccepted();
Refresh();
}
void MyApp::DragLeave()
{
LOG("DragLeave"); // this never gets called
CancelMode();
}
void MyApp::CancelMode()
{
LOG("CancelMode");
dnd = false;
Refresh();
}
GUI_APP_MAIN
{
MyApp().Run();
}
Aren't we missing something? There's something I do not quite fully understand here, I mean, how is our code supposed to acknowledge it should accept DnD data from other non-Upp Windows processes? Doesn't Windows require us to somehow register our Upp process as potential target of DnD events?
Thanks again!
|
|
|
|
|
Re: Image DnD into Upp app [message #44173 is a reply to message #44171] |
Thu, 15 January 2015 19:06 |
|
bushman
Messages: 134 Registered: February 2009
|
Experienced Member |
|
|
Hi, Mirek, tks for your help, it's weird indeed, I've run a number of tests on both of my systems and here's my feedback on some of the points you raised:
Quote:What is your OS exactly? Compiler?
Windows 7 - MSC9 and Windows 8.1 - MSC9 and MSC10
Quote:As first quick test, does DnD of text to theide work for you?
No, it doesn't work in Win 8.1, but it does work in Win 7.
Quote:Alternatively, you can test with examples/UWord, with Image.
Did that, pls review code posted below, which I used to run tests, along with attached table pics summarizing results:
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
struct MyApp : TopWindow {
virtual void CancelMode();
virtual void Paint(Draw& w);
virtual void DragAndDrop(Point p, PasteClip& d);
virtual void DragLeave();
Image img;
String txt;
bool dnd;
MyApp() { dnd = false; }
};
void MyApp::Paint(Draw& w)
{
Size sz = GetSize();
w.DrawRect(sz, dnd ? SColorInfo() : SColorFace());
w.DrawImage(0, 0, img);
w.DrawText(10, 10, txt);
}
void MyApp::DragAndDrop(Point p, PasteClip& d)
{
LOG("DragAndDrop");
if(AcceptImage(d)) {
img = GetImage(d);
txt = "";
} else if(AcceptText(d)) {
txt = GetString(d);
img.Clear();
}
dnd = d.IsAccepted();
Refresh();
}
void MyApp::DragLeave()
{
LOG("DragLeave");
CancelMode();
}
void MyApp::CancelMode()
{
LOG("CancelMode");
dnd = false;
Refresh();
}
GUI_APP_MAIN
{
MyApp().Run();
}
Could these erratic results be due to non-standardized Windows DnD obj formatting from one version to another?
Tks!
-
Attachment: table1.png
(Size: 37.62KB, Downloaded 803 times)
-
Attachment: table2.png
(Size: 38.76KB, Downloaded 721 times)
|
|
|
|
Re: Image DnD into Upp app [message #44175 is a reply to message #44173] |
Thu, 15 January 2015 20:58 |
|
mirek
Messages: 14039 Registered: November 2005
|
Ultimate Member |
|
|
kropniczki wrote on Thu, 15 January 2015 19:06Hi, Mirek, tks for your help, it's weird indeed, I've run a number of tests on both of my systems and here's my feedback on some of the points you raised:
Quote:What is your OS exactly? Compiler?
Windows 7 - MSC9 and Windows 8.1 - MSC9 and MSC10
Quote:As first quick test, does DnD of text to theide work for you?
No, it doesn't work in Win 8.1, but it does work in Win 7.
Quote:Alternatively, you can test with examples/UWord, with Image.
Did that, pls review code posted below, which I used to run tests, along with attached table pics summarizing results:
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
struct MyApp : TopWindow {
virtual void CancelMode();
virtual void Paint(Draw& w);
virtual void DragAndDrop(Point p, PasteClip& d);
virtual void DragLeave();
Image img;
String txt;
bool dnd;
MyApp() { dnd = false; }
};
void MyApp::Paint(Draw& w)
{
Size sz = GetSize();
w.DrawRect(sz, dnd ? SColorInfo() : SColorFace());
w.DrawImage(0, 0, img);
w.DrawText(10, 10, txt);
}
void MyApp::DragAndDrop(Point p, PasteClip& d)
{
LOG("DragAndDrop");
if(AcceptImage(d)) {
img = GetImage(d);
txt = "";
} else if(AcceptText(d)) {
txt = GetString(d);
img.Clear();
}
dnd = d.IsAccepted();
Refresh();
}
void MyApp::DragLeave()
{
LOG("DragLeave");
CancelMode();
}
void MyApp::CancelMode()
{
LOG("CancelMode");
dnd = false;
Refresh();
}
GUI_APP_MAIN
{
MyApp().Run();
}
Could these erratic results be due to non-standardized Windows DnD obj formatting from one version to another?
Tks!
I would not read too much into File Explorer source - these are expected - UWord expects (now) that you are dropping qtf formated files, which these images are not.... (of course, would be nice to automatically open images too...)
Have you tried with U++ apps as source? (E.g. UWord->MSWord)
Another: please try e.g. Firefox or Chrome as source of images.
Mirek
|
|
|
Re: Image DnD into Upp app [message #44176 is a reply to message #44175] |
Thu, 15 January 2015 21:11 |
|
mirek
Messages: 14039 Registered: November 2005
|
Ultimate Member |
|
|
Also please try this logging:
STDMETHODIMP UDropTarget::DragEnter(LPDATAOBJECT pDataObj, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect)
{
GuiLock __;
LLOG("DragEnter " << pt);
data = pDataObj;
data->AddRef();
fmt.Clear();
IEnumFORMATETC *fe;
if(!ctrl || pDataObj->EnumFormatEtc(DATADIR_GET, &fe) != NOERROR) {
*pdwEffect = DROPEFFECT_NONE;
return NOERROR;
}
FORMATETC fmtetc;
while(fe->Next(1, &fmtetc, 0) == S_OK) {
fmt.FindAdd(FromWin32CF(fmtetc.cfFormat));
if(fmtetc.ptd)
CoTaskMemFree(fmtetc.ptd);
}
fe->Release();
DUMP(fmt)
DnD(pt, false, pdwEffect, grfKeyState);
return NOERROR;
}
That should show formats available.
Actually, from table you have posted, only MS Word -> theide/UWord make me really worried... Note that UWord does not support gif (forgot to add plugin/gif) and bmp format is tricky...
|
|
|
Re: Image DnD into Upp app [message #44177 is a reply to message #44175] |
Thu, 15 January 2015 23:26 |
|
bushman
Messages: 134 Registered: February 2009
|
Experienced Member |
|
|
Quote:Have you tried with U++ apps as source? (E.g. UWord->MSWord)
Don't recall any Upp app example that exposes imgs to DnD operations for now, so I limited my tests just to texts.
Quote:Actually, from table you have posted, only MS Word -> theide/UWord make me really worried...
Win8.1 - MSC10:
---------------
TEXT: UWord -> MSWord = ok.
TEXT: MSWord -> TheIDE = failed.
TEXT: MSWord -> UWord = failed, format DUMP:
* C:\upp\out\examples\MSC10.Debug.Debug_Full.Gui.Mt\UWord.exe 15.01.2015 18:19:00, user: admin
fmt = [text/QTF, Rich Text Format, text/rtf, application/rtf, wtext, text]
data = Memory at 03A71D38, size 0x10B = 267
+0 0x03A71D38 7B 5C 72 74 66 31 5C 61 6E 73 69 5C 61 6E 73 69 {\rtf1\ansi\ansi
+16 0x03A71D48 63 70 67 31 32 35 32 5C 64 65 66 66 30 7B 5C 66 cpg1252\deff0{\f
+32 0x03A71D58 6F 6E 74 74 62 6C 7B 5C 66 30 5C 66 73 77 69 73 onttbl{\f0\fswis
+48 0x03A71D68 73 5C 66 63 68 61 72 73 65 74 30 20 41 72 69 61 s\fcharset0 Aria
+64 0x03A71D78 6C 3B 7D 7B 5C 66 31 5C 66 74 65 63 68 5C 66 63 l;}{\f1\ftech\fc
+80 0x03A71D88 68 61 72 73 65 74 32 20 53 79 6D 62 6F 6C 3B 7D harset2 Symbol;}
+96 0x03A71D98 7B 5C 66 32 5C 66 63 68 61 72 73 65 74 30 20 57 {\f2\fcharset0 W
+112 0x03A71DA8 69 6E 67 64 69 6E 67 73 3B 7D 7D 7B 5C 73 74 79 ingdings;}}{\sty
+128 0x03A71DB8 6C 65 73 68 65 65 74 7B 5C 73 30 5C 73 62 61 73 lesheet{\s0\sbas
+144 0x03A71DC8 65 64 6F 6E 32 32 32 20 44 65 66 61 75 6C 74 3B edon222 Default;
+160 0x03A71DD8 7D 7D 5C 70 61 70 65 72 77 31 31 39 30 34 5C 70 }}\paperw11904\p
+176 0x03A71DE8 61 70 65 72 68 31 36 38 33 36 5C 6D 61 72 67 6C aperh16836\margl
+192 0x03A71DF8 31 31 33 33 5C 6D 61 72 67 72 31 31 33 33 5C 6D 1133\margr1133\m
+208 0x03A71E08 61 72 67 74 31 31 33 33 5C 6D 61 72 67 62 31 31 argt1133\margb11
+224 0x03A71E18 33 33 5C 73 30 5C 70 61 72 64 5C 66 73 32 34 5C 33\s0\pard\fs24\
+240 0x03A71E28 6C 61 6E 67 31 30 33 33 20 66 6B 6A 66 5C 75 32 lang1033 fkjf\u2
+256 0x03A71E38 33 31 3F 68 75 69 6F 71 72 75 7D 31?huioqru}
Windows 7 - MSC9:
-----------------
TEXT: UWord -> MSWord = ok.
TEXT: MSWord -> TheIDE = ok.
TEXT: MSWord -> UWord = ok.
Quote:
Note that UWord does not support gif (forgot to add plugin/gif) and bmp format is tricky...
As to what imgs are concerned, I'll be trying just jpeg's though.
Quote:
Another: please try e.g. Firefox or Chrome as source of images.
Windows 8.1 - MSC10:
--------------------
JPG: Firefox -> UWord = failed, no DUMP generated.
JPG: MSWord -> UWord = failed, no DUMP generated.
Windows 7 - MSC9:
-----------------
JPG: Firefox -> UWord = ok, DUMP:
* C:\upp\out\examples\MSC9.Debug.Debug_Full.Gui\UWord.exe 15.01.2015 19:00:32, user: admin
fmt = [text/x-moz-url, FileGroupDescriptor, FileGroupDescriptorW, FileContents, UniformResourceLocator, UniformResourceLocatorW, text/x-moz-url-data, text/x-moz-url-desc, text/uri-list, text/_moz_htmlcontext, text/_moz_htmlinfo, text/html, HTML Format, wtext, text, application/x-moz-nativeimage, ¤"_þ@ 0ó, dib, files, Preferred DropEffect, application/x-moz-file-promise-url, application/x-moz-file-promise-dest-filename, DragImageBits, DragContext]
JPG: MSWord -> UWord = failed, drops just blank image frame, DUMP:
* C:\upp\out\examples\MSC9.Debug.Debug_Full.Gui\UWord.exe 15.01.2015 19:04:35, user: admin
fmt = [Woozle, Object Descriptor, Rich Text Format, HTML Format, text, wtext, "Šü`û0ó, Embed Source]
{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff31507\deff0\stshfdbch31506\stshfloch31506\stshfhich31506\stshfbi31507\deflang1046\deflangfe1046\themelang1046\themelangfe0\themelangcs0{\fonttbl{\f0\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f1\fbidi \fswiss\fcharset0\fprq2{\*\panose 020b0604020202020204}Arial;}
{\f34\fbidi \froman\fcharset1\fprq2{\*\panose 02040503050406030204}Cambria Math;}{\f37\fbidi \fswiss\fcharset0\fprq2{\*\panose 020f0502020204030204}Calibri;}{\flomajor\f31500\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}.................TO LONG TO INCLUDE IN THIS MESSAGE...........
Hope it helps!
tks!
|
|
|
|
Re: Image DnD into Upp app [message #44179 is a reply to message #44178] |
Fri, 16 January 2015 21:41 |
|
bushman
Messages: 134 Registered: February 2009
|
Experienced Member |
|
|
Here are my test results for now, pls observe we got no issues whatsoever related to any copy/paste operations, whereas mixed results were obtained for DnD.
Windows 7 - MSC9:
Copy(JPG, MSWord) -> Paste(UWord) == ok, no DUMP created
Drag(JPG, MSWord) -> Drop(UWord) == failed, DUMP:
* C:\upp\out\examples\MSC9.Debug.Debug_Full.Gui\UWord.exe 16.01.2015 16:48:58, user: admin
fmt = [Art::GVML ClipFormat, n0, PNG, JFIF, GIF, yi, Object Descriptor]
Copy(TEXT, MSWord) -> Paste(UWord) == ok, big DUMP
Drag(TEXT, MSWord) -> Drop(UWord) == ok, big DUMP
Copy(JPG, Firefox) -> Paste(UWord) == ok, no DUMP generated.
Drag(JPG, Firefox) -> Drop(UWord) == ok, DUMP:
* C:\upp\out\examples\MSC9.Debug.Debug_Full.Gui\UWord.exe 16.01.2015 16:58:39, user: admin
fmt = [text/x-moz-url, FileGroupDescriptor, FileGroupDescriptorW, FileContents, UniformResourceLocator, UniformResourceLocatorW, text/x-moz-url-data, text/x-moz-url-desc, text/uri-list, text/_moz_htmlcontext, text/_moz_htmlinfo, text/html, HTML Format, wtext, text, application/x-moz-nativeimage, ds_@0, dib, files, Preferred DropEffect, application/x-moz-file-promise-url, application/x-moz-file-promise-dest-filename, DragImageBits, DragContext]
Copy(TEXT, Firefox) -> Paste(UWord) == ok, no DUMP generated.
Drag(TEXT, Firefox) -> Drop(UWord) == ok, DUMP:
* C:\upp\out\examples\MSC9.Debug.Debug_Full.Gui\UWord.exe 16.01.2015 17:08:36, user: admin
fmt = [text/_moz_htmlcontext, text/_moz_htmlinfo, text/html, HTML Format, wtext, text, DragImageBits, DragContext]
------------------------------------------------------------ ---------------------------------------------
Windows 8.1 - MSC9:
Copy(TEXT, MSWord) -> Paste(UWord) == ok, big DUMP.
Drag(TEXT, MSWord) -> Drop(UWord) == failed, no DUMP generated.
Copy(JPG, MSWord) -> Paste(UWord) == ok, no DUMP generated.
Drag(JPG, MSWord) -> Drop(UWord) == failed, no DUMP generated.
Copy(TEXT, Firefox) -> Paste(UWord) == ok, no DUMP generated.
Drag(TEXT, Firefox) -> Drop(UWord) == failed, no DUMP generated.
Copy(JPG, Firefox) -> Paste(UWord) == ok, no DUMP generated.
Drag(JPG, Firefox) -> Drop(UWord) == failed, no Dump Generated.
tks.
|
|
|
|
|
|
Re: Image DnD into Upp app [message #44183 is a reply to message #44182] |
Sun, 18 January 2015 11:44 |
|
bushman
Messages: 134 Registered: February 2009
|
Experienced Member |
|
|
Bingo! Absolutely correct! Text DnD from MS Word to UWord works perfectly in Win8.1 when UWord starts from shell, just as you pointed out. Great!
Yet, although image copy/paste works like a charm for both, Win 8.1 and 7, can't DnD JPG from MS Word to Uword still. Dump shows:
WIN8.1 - MSC9:
* C:\upp\out\examples\MSC9.Debug.Debug_Full.Gui.Mt\UWord.exe 18.01.2015 07:12:54, user: admin
fmt = [Art::GVML ClipFormat, ˜íSü@
®Ìï, PNG, JFIF, GIF, ,ÿ¯ûàRÌï, Object Descriptor]
WIN 7 - MSC9:
* C:\upp\out\examples\MSC9.Debug.Debug_Full.Gui\UWord.exe 18.01.2015 07:21:41, user: admin
fmt = [Woozle, Object Descriptor, Rich Text Format, HTML Format, text, wtext, F...ùü 0ó, Embed Source]
{\rtf1\ad...
... FOLLOWS EXTENSIVE TEXT APPARENTLY ON FONT/TEXT FORMATTING PARAMETERS .....
... FOLLOWED BY WHAT I GUESS TO BE ABOUT PICTURE FORMATTING:
{\*\shppict
{\pict{\*\picprop\shplid1025{\sp{\sn shapeType}{\sv 75}}{\sp{\sn fFlipH}{\sv 0}}{\sp{\sn fFlipV}{\sv 0}}{\sp{\sn fRotateText}{\sv 1}}{\sp{\sn pictureGray}{\sv 0}}{\sp{\sn pictureBiLevel}{\sv 0}}{\sp{\sn fFilled}{\sv 0}}{\sp{\sn fNoFillHitTest}{\sv 0}}
{\sp{\sn fLine}{\sv 0}}{\sp{\sn wzName}{\sv Imagem 4}}{\sp{\sn fHidden}{\sv 0}}{\sp{\sn fLayoutInCell}{\sv 1}}}\picscalex99\picscaley100\piccropl0\piccropr0\piccropt0\ piccropb0
\picw1194\pich1372\picwgoal677\pichgoal778\pngblip\bliptag21 44142166{\*\blipuid 7fcd0
... IMAGE HEX DATA ...
6082}}{\nonshppict
{\pict\picscalex100\picscaley100\piccropl0\piccropr0\piccrop t0\piccropb0\picw1194\pich1372\picwgoal677\pichgoal778\wmeta file8\bliptag2144142166\blipupi99{\*\blipuid 7fcd035608425ad3a4e38021e206889b}... MORE HEX DATA ...
... EOF
Note: Windows-7 UWord shows just a blank image frame after dropping operation.
Thank you!
|
|
|
|
|
|
|
Goto Forum:
Current Time: Fri Sep 20 18:06:36 CEST 2024
Total time taken to generate the page: 0.04139 seconds
|