Help with a fix you implemented back in v1.3.1 of editcontrl

The place for programming-related topics.
Post Reply
LIGHTNING UK!
Cadet
Posts:1
Joined:13 Dec 2009, 22:06
Help with a fix you implemented back in v1.3.1 of editcontrl

Post by LIGHTNING UK! » 13 Dec 2009, 22:15

Hi,

I've recently discovered that my application (done in C++ Builder) appears to suffer from a problem you fixed back in v1.3.1 of EditControls and was wondering if you'd be kind enough to tell me what you did?!

The fix in question is this one:

"- FIX: Drop descriptions didn't work as expected if the drag source was a 64 bit app."

In my own tool, when I drag from Explorer or something else 64bit, I get the nice big drag image ok but the description doesn't show up at all (even though the function to set it IS being called). Another odd thing is that I still get the old style cursors and not the newer looking ones with blue '+' or red '0' by the side of them (if that makes sense).

If I open 2 instances of my program and drag from an 'open file' dialog box, everything works perfectly... so it's just a 64bit -> 32bit issue like the one you appear to have had back in 2008.

I must also say 'Thank You' for your input to a thread about the Vista drag+drop stuff that I came across via a Google search (and to be fair, that's why I'm here asking for your help now). Without it, I'd probably still (months later) be searching for the info I needed!

User avatar
TiKu
Administrator
Administrator
Posts:832
Joined:28 Sep 2004, 21:10
Location:Unterföhring
Contact:

Re: Help with a fix you implemented back in v1.3.1 of editcontrl

Post by TiKu » 14 Dec 2009, 09:20

I've changed many things on Aero drag images since I wrote the post you found with Google. But I'll have a look at the repository what I changed for EditControls 1.3.1.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!

User avatar
TiKu
Administrator
Administrator
Posts:832
Joined:28 Sep 2004, 21:10
Location:Unterföhring
Contact:

Re: Help with a fix you implemented back in v1.3.1 of editcontrl

Post by TiKu » 15 Dec 2009, 09:11

Here's what I changed:

Code: Select all

HRESULT InvalidateDragWindow(LPDATAOBJECT pDataObject)
{
	if(!pDataObject) {
		return E_POINTER;
	}

	HRESULT hr = E_FAIL;

	FORMATETC format = {0};
	STGMEDIUM medium = {0};

	format.cfFormat = static_cast<CLIPFORMAT>(RegisterClipboardFormat(TEXT("DragWindow")));
	format.dwAspect = DVASPECT_CONTENT;
	format.lindex = -1;
	format.tymed = TYMED_HGLOBAL;
	if(SUCCEEDED(pDataObject->GetData(&format, &medium))) {
		if(medium.hGlobal) {
			#define WM_INVALIDATEDRAGIMAGE	WM_USER + 3     // (wParam = 0, lParam = 0)

			HWND hWndDragWindow = *reinterpret_cast<HWND*>(GlobalLock(medium.hGlobal));
			GlobalUnlock(medium.hGlobal);
			if(hWndDragWindow) {
				SendMessage(hWndDragWindow, WM_INVALIDATEDRAGIMAGE, 0, 0);
				hr = S_OK;
			}
		}
		ReleaseStgMedium(&medium);
	}
	return hr;
}
Then on DragEnter and DragMove, call this method (just before returning S_OK) with the dragged data object.

Hope this helps.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!

Post Reply