U++ framework
Do not panic. Ask here before giving up.

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 Go to next message
bushman is currently offline  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 #44169 is a reply to message #44168] Wed, 14 January 2015 19:21 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
#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)
{
	if(AcceptImage(d))
		img = GetImage(d);
	dnd = d.IsAccepted();
	Refresh();
}

void MyApp::DragLeave()
{
	CancelMode();
}

void MyApp::CancelMode()
{
	dnd = false;
	Refresh();
}

GUI_APP_MAIN
{
	MyApp().Run();
}
Re: Image DnD into Upp app [message #44170 is a reply to message #44169] Wed, 14 January 2015 22:09 Go to previous messageGo to next message
bushman is currently offline  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 #44171 is a reply to message #44170] Thu, 15 January 2015 08:51 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
Now that is really weird. Of course, I have tested my code before posting here (with Win8 and now Win7).

As first quick test, does DnD of text to theide work for you?

Alternatively, you can test with examples/UWord, with Image.

What is your OS exactly? Compiler?

As for your question, U++ does all that for you. All you need to do is to call "Accept" for format that you, ehm, accept...

Mirek
Re: Image DnD into Upp app [message #44172 is a reply to message #44170] Thu, 15 January 2015 08:51 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3458
Registered: August 2008
Senior Veteran
Hello kropniczki
Quote:
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?

I copy and paste daily data as formatted texts and tables from/to U++/Microsoft applications without problems so I imagine your problem is very specific to images in some particular situation.


Best regards
Iñaki
Re: Image DnD into Upp app [message #44173 is a reply to message #44171] Thu, 15 January 2015 19:06 Go to previous messageGo to next message
bushman is currently offline  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();
}

index.php?t=getfile&id=4706&private=0

index.php?t=getfile&id=4707&private=0

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 1090 times)
  • Attachment: table2.png
    (Size: 38.76KB, Downloaded 1008 times)
Re: Image DnD into Upp app [message #44174 is a reply to message #44172] Thu, 15 January 2015 19:17 Go to previous messageGo to next message
bushman is currently offline  bushman
Messages: 134
Registered: February 2009
Experienced Member
koldo wrote on Thu, 15 January 2015 02:51
Hello kropniczki
Quote:
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?

I copy and paste daily data as formatted texts and tables from/to U++/Microsoft applications without problems so I imagine your problem is very specific to images in some particular situation.


Hi, Koldo!
Good for you and all other users who may not be facing the same issues, and I hope you're right about it being something specific to my situation. Nevertheless, please observe that I performed tests on two different Windows OS configurations and got mixed results as you can see in the reply I posted on Mirek's response in this topic.

Appreciate your concerns, tks!
Re: Image DnD into Upp app [message #44175 is a reply to message #44173] Thu, 15 January 2015 20:58 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
kropniczki wrote on Thu, 15 January 2015 19:06
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();
}

index.php?t=getfile&id=4706&private=0

index.php?t=getfile&id=4707&private=0

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 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
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 Go to previous messageGo to next message
bushman is currently offline  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 #44178 is a reply to message #44177] Fri, 16 January 2015 09:16 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
Another thing to try: Instead of DnD, please use clipboard (Copy, Paste). It is using the same file formats, will tell us whether it is file format issue or something else...

Mirek
Re: Image DnD into Upp app [message #44179 is a reply to message #44178] Fri, 16 January 2015 21:41 Go to previous messageGo to next message
bushman is currently offline  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, n0, 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 #44180 is a reply to message #44177] Sat, 17 January 2015 16:19 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
As for JPG: MSWord -> UWord, from the log you have posted, it looks like the problem is that MSWord actually presents it as text (rich text) and our RTF parser does not understand JPG in RTF. I am adding RM issue to add JPG support in ParseRTF....

So it looks like copy/paste is mostly working, but DnD is not.

For now, let us concentrate just on MS Word text -> UWord in Windows 8.1. Could you please activate general logging in Win32DnD.cpp at the start of file:

#define LLOG(x) LOG(x)

(uncomment // LOG(x))

try dragging text to UWord, post result here?

Mirek
Re: Image DnD into Upp app [message #44181 is a reply to message #44180] Sat, 17 January 2015 18:10 Go to previous messageGo to next message
bushman is currently offline  bushman
Messages: 134
Registered: February 2009
Experienced Member
mirek wrote on Sat, 17 January 2015 10:19


For now, let us concentrate just on MS Word text -> UWord in Windows 8.1. Could you please activate general logging in Win32DnD.cpp at the start of file:

#define LLOG(x) LOG(x)

(uncomment // LOG(x))

try dragging text to UWord, post result here?

Mirek


Did that, all attempts failed and no log ever gets created when dragging text from MS Word into UWord in Win 8.1.

Eddy.
Re: Image DnD into Upp app [message #44182 is a reply to message #44181] Sun, 18 January 2015 09:18 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
Just found this:

http://www.eightforums.com/general-support/15434-drag-drop-p roblem.html

Any chances you are running theide (and AFAIK the program you launch from theide) in admin mode or something?

The pattern you show indicates right that: you can DnD between theide and uword (I supposed you started it from theide), but not between external application and theide/uword...

Might be interesting to start uword from shell, not theide...

Mirek
Re: Image DnD into Upp app [message #44183 is a reply to message #44182] Sun, 18 January 2015 11:44 Go to previous messageGo to next message
bushman is currently offline  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!
Re: Image DnD into Upp app [message #44185 is a reply to message #44168] Sun, 18 January 2015 11:56 Go to previous messageGo to next message
bushman is currently offline  bushman
Messages: 134
Registered: February 2009
Experienced Member
Win7 MSWord -> UWord JGP DnD now dumps
* C:\upp\out\examples\MSC9.Debug.Debug_Full.Gui\UWord.exe 18.01.2015 07:52:02, user: admin
fmt = [Art::GVML ClipFormat, ÜŒkýÀ"0ó, PNG, JFIF, GIF, 0'ü Ø0ó, Object Descriptor]
,instead of very extensive file (?!)

tks.
Re: Image DnD into Upp app [message #44186 is a reply to message #44185] Mon, 19 January 2015 11:41 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
OK, the rest appears to be format issue.

I do not have MS Word to test, so I would like to ask for more data:

bool   PasteClip::Accept(const char *_fmt)
{
	Vector<String> f = Split(_fmt, ';');
	for(int i = 0; i < f.GetCount(); i++) {
		if(IsAccepted() && fmt == f[i])
			return paste;
		if(IsAvailable(f[i])) {
			accepted = true;
			if(paste) {
				fmt = f[i];
				DDUMP(fmt); // NEW
				data = Get(f[i]);
				SaveFile(GetHomeDirFile("data.bin"), data); // NEW, Set appropriate path here....
				return true;
			}
			break;
		}
	}
	return false;
}


then D&D JPG from MSWORD->UWORD, post format here and zipped data.bin...

Mirek
Re: Image DnD into Upp app [message #44187 is a reply to message #44186] Mon, 19 January 2015 19:59 Go to previous messageGo to next message
bushman is currently offline  bushman
Messages: 134
Registered: February 2009
Experienced Member
Mirek,

Attached files data.bin and UWord.log as requested.
Pls note that these files regard results of tests done on Win7 only. Same test does not create any log or bin file in Win8.1; checked variable 'fmt' in for-loop and it is always empty; execution never goes into scope of if(IsAvailable(fmt[i])).

Thank you!

  • Attachment: Downloads.zip
    (Size: 54.16KB, Downloaded 343 times)
Re: Image DnD into Upp app [message #44189 is a reply to message #44187] Tue, 20 January 2015 14:44 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
Thanks. I have fixed ParserRTF, so it is now able to load that data correctly.

Mirek
Re: Image DnD into Upp app [message #44199 is a reply to message #44189] Thu, 22 January 2015 21:18 Go to previous messageGo to next message
bushman is currently offline  bushman
Messages: 134
Registered: February 2009
Experienced Member
Hello, Mirek,

Splendid! Almost there...

...works great in Win7 now, but still does not drop jpg from MS Word into UWord in Win8.1. Test output creates a blank data.bin and this fmt LOG:
* C:\upp\out\examples\MSC9.Debug.Debug_Full.Gui.Mt\UWord.exe 22.01.2015 17:05:00, user: admin
fmt = dib

DnD jpg from File Explorer into UWord works perfectly in both OS versions.

Any hint on what to try next?

Many thanks!!!


Re: Image DnD into Upp app [message #44202 is a reply to message #44199] Fri, 23 January 2015 09:43 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
bushman wrote on Thu, 22 January 2015 21:18
Hello, Mirek,

Splendid! Almost there...

...works great in Win7 now, but still does not drop jpg from MS Word into UWord in Win8.1. Test output creates a blank data.bin and this fmt LOG:
* C:\upp\out\examples\MSC9.Debug.Debug_Full.Gui.Mt\UWord.exe 22.01.2015 17:05:00, user: admin
fmt = dib

DnD jpg from File Explorer into UWord works perfectly in both OS versions.

Any hint on what to try next?

Many thanks!!!




Well, looks like problem with dib... Some more logs:

Image GetImage(PasteClip& clip)
{
	GuiLock __;
	Image m;
	if(Accept<Image>(clip)) {
		LoadFromString(m, ~clip);
		if(!m.IsEmpty())
			return m;
	}
	if(clip.Accept("dib")) {
LOG("DIB accepted");
		String data = ~clip;
		if((unsigned)data.GetCount() < sizeof(BITMAPINFO)) return Null;
LOG("DIB accepted 2");
		BITMAPINFO *lpBI = 	(BITMAPINFO *)~data;
		BITMAPINFOHEADER& hdr = lpBI->bmiHeader;
		byte *bits = (byte *)lpBI + hdr.biSize;
		if(hdr.biBitCount <= 8)
			bits += (hdr.biClrUsed ? hdr.biClrUsed : 1 << hdr.biBitCount) * sizeof(RGBQUAD);
		if(hdr.biBitCount >= 16 || hdr.biBitCount == 32) {
			if(hdr.biCompression == 3)
				bits += 12;
			if(hdr.biClrUsed != 0)
				bits += hdr.biClrUsed * sizeof(RGBQUAD);
		}
DUMP(bits);
DUMP((int)hdr.biHeight);
DUMP((int)hdr.biWidth);
		int h = abs((int)hdr.biHeight);
		ImageDraw   iw(hdr.biWidth, h);
		::StretchDIBits(iw.GetHandle(),
			0, 0, hdr.biWidth, h,
			0, 0, hdr.biWidth, h,
			bits, lpBI, DIB_RGB_COLORS, SRCCOPY);
		return iw;
	}
	return Null;
}


Thanks!

Mirek
Re: Image DnD into Upp app [message #44204 is a reply to message #44202] Fri, 23 January 2015 17:07 Go to previous messageGo to next message
ManfredHerr is currently offline  ManfredHerr
Messages: 67
Registered: February 2013
Location: Germany
Member
I want to let you know that my UBUNTU 14.04 (AMD64) refuses the Drag and Drop operation as well.

A recent update of UPP brought in "reference" a DragAndDropImg. I generated an executable with "GUI" and "GCC Optimal". When I ran it I kept it in the starter. Both times, when active or only in the starter, dragging bushman's avatar to the starter lit Firefox and Gimp only, but not the unnamed application DragAndDropImg. So I can drop the image to Firefox or Gimp, but not to DragAndDropImg.
Re: Image DnD into Upp app [message #44205 is a reply to message #44202] Fri, 23 January 2015 22:14 Go to previous messageGo to next message
bushman is currently offline  bushman
Messages: 134
Registered: February 2009
Experienced Member
Mirek,

tried out your latest advice, size of accepted data does not match size of BITMAPINFO struct (data.GetCount() == 0):
* C:\upp\out\examples\MSC9.Debug.Debug_Full.Gui.Mt\UWord.exe 23.01.2015 16:02:45, user: admin
DIB accepted


Just a few Side Comments:
Maybe it's something specific to my Win8.1 installation after all. This time I also did a few tests dragging jpg from MS Word into both LibreOffice and OpenOffice Writer and they failed too, showing only blank img frames over a doc background.
Both LibreOffice and OpenOffice show context menu options to dialogs to manipulate imgs when you right-click on img frame icon. These dialog boxes however show copies of the DnDropped img thumbs, which they save in a TMP file. So I'm confused: how come the img can't be shown on document while they save and show it correctly from a TMP file?

Thank you once more, for your patience!
Re: Image DnD into Upp app [message #44206 is a reply to message #44205] Sat, 24 January 2015 11:49 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
bushman wrote on Fri, 23 January 2015 22:14
Mirek,

tried out your latest advice, size of accepted data does not match size of BITMAPINFO struct (data.GetCount() == 0):
* C:\upp\out\examples\MSC9.Debug.Debug_Full.Gui.Mt\UWord.exe 23.01.2015 16:02:45, user: admin
DIB accepted


Just a few Side Comments:
Maybe it's something specific to my Win8.1 installation after all. This time I also did a few tests dragging jpg from MS Word into both LibreOffice and OpenOffice Writer and they failed too, showing only blank img frames over a doc background.
Both LibreOffice and OpenOffice show context menu options to dialogs to manipulate imgs when you right-click on img frame icon. These dialog boxes however show copies of the DnDropped img thumbs, which they save in a TMP file. So I'm confused: how come the img can't be shown on document while they save and show it correctly from a TMP file?

Thank you once more, for your patience!


Well, let us see what word really puts there... It looks really weird, like data are truncated or not complete or perhaps contain some HANDLE...

	if(clip.Accept("dib")) {
LOG("DIB accepted");
		String data = ~clip;
DUMPHEX(data);
Re: Image DnD into Upp app [message #44207 is a reply to message #44206] Sat, 24 January 2015 15:21 Go to previous messageGo to next message
bushman is currently offline  bushman
Messages: 134
Registered: February 2009
Experienced Member
Quote:
Well, let us see what word really puts there... It looks really weird, like data are truncated or not complete or perhaps contain some HANDLE...

if(clip.Accept("dib")) {
LOG("DIB accepted");
String data = ~clip;
DUMPHEX(data);


I got no data back!
* C:\upp\out\examples\MSC9.Debug.Debug_Full.Gui.Mt\UWord.exe 24.01.2015 10:52:52, user: admin
DIB accepted
data = Memory at 0018E754, size 0x0 = 0


tks.
Re: Image DnD into Upp app [message #44211 is a reply to message #44207] Mon, 26 January 2015 19:05 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
OK, let us try this:

String UDropTarget::Get(const char *fmt) const
{
	FORMATETC fmtetc = ToFORMATETC(fmt);
	STGMEDIUM s;
        HRESULT hr = data->GetData(&fmtetc, &s);
        DDUMP(hr); DDUMP(hr == S_OK); DDUMP(s.tymed); DDUMP(s.tymed == TYMED_HGLOBAL);
	if(hr == S_OK && s.tymed == TYMED_HGLOBAL) {
		char *val = (char *)GlobalLock(s.hGlobal);
		String data(val, (int)GlobalSize(s.hGlobal));
		GlobalUnlock(s.hGlobal);
		ReleaseStgMedium(&s);
		return data;
    }
	return Null;
}


Thanks for patience. And keep that Win installation, it is a good testing environment Smile
Re: Image DnD into Upp app [message #44213 is a reply to message #44211] Mon, 26 January 2015 21:24 Go to previous message
bushman is currently offline  bushman
Messages: 134
Registered: February 2009
Experienced Member
Quote:
Thanks for patience. And keep that Win installation, it is a good testing environment Smile

Actually, I'm just waiting for the last straw that will make me format my Win8 system. This OS version should be codenamed "Windows Nightmare" instead. Smile

Well, here we go again:
* C:\upp\out\examples\MSC9.Debug.Debug_Full.Gui.Mt\UWord.exe 26.01.2015 16:57:39, user: admin
hr = -2147221404
hr == ((HRESULT)0L) = false
s.tymed = 0
s.tymed == TYMED_HGLOBAL = false
DIB accepted
data = Memory at 0018E754, size 0x0 = 0


Tks!

Previous Topic: Context Menu request
Next Topic: rounding to decimals implementation
Goto Forum:
  


Current Time: Tue Apr 28 15:08:47 GMT+2 2026

Total time taken to generate the page: 0.00997 seconds