Dragging and dropping from IE 9 to my application

This is some weird problem, let me try to explain. I wrote a (dialog) app in C ++ / MFC that supports drag-n-dropping.

I am doing the following test on Windows 7 with default themes. My app runs on screen. It is not the top window (in its z-order), or in other words, it is shaded by other windows on top of it.

If I start dragging a link, or just select text from Chrome or Firefox browser, first to my application icon on the taskbar, the icon starts blinking and my application appears on the screen (getting the top z-order) so I can drag into the application. Everything works fine.

If I do the same from IE 9 (version 9.0.8112, update version 9.0.12), when I drag the selected text or link first to my app's taskbar icon so that my app becomes the top window (in z-order), the app icon keeps blinking, but it never appears on the screen like it does with Chrome or FF, so I have to give up the drag.

Any idea why this is happening with IE and if there is a way to fix it?

EDIT: Here is some sample code in relation to my comments below:

HRESULT __stdcall DragEnter(IDataObject* pDataObject, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect)
{
    //IDropTarget::DragEnter
    m_fAllowDrop = QueryDataObject(pDataObject);

    if(m_fAllowDrop)
    {
        //SUCCESS
        // get the dropeffect based on keyboard state
    }
    else
    {
        //FAILURE
        *pdwEffect = DROPEFFECT_NONE;
    }

    return S_OK;
}

BOOL QueryDataObject(IDataObject* pDataObject, int* pnOutDataType)
{
    static FORMATETC fmtetc_file = {CF_HDROP, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
    static FORMATETC fmtetc_txt = {CF_UNICODETEXT, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};

    BOOL bRes = FALSE;
    HRESULT hr;

    //See if our data type
    hr = pDataObject->QueryGetData(&fmtetc_file);
    if(hr == S_OK)
    {
        bRes = TRUE;
    }

    //In my case hr is E_FAIL or 0x80004005

    hr = pDataObject->QueryGetData(&fmtetc_txt);
    if(hr == S_OK)
    {
        bRes = TRUE;
    }

    //In my case hr is E_FAIL or 0x80004005

    return bRes;
}

      

+3


source to share


1 answer


As part of its sandbox to prevent unauthorized changes to the computer, Internet Explorer runs at a lower UIPI (user interface) integrity level than other applications. So it doesn't have permission to access your application by default, which is likely to run at high or medium UIPI integrity level (depending on whether it's UAC elevated or not). A blinking taskbar button means that something is trying to bring your app to the front, but it does not have permission to do so (see documentationSetForegroundWindow()

for more details). UIPI prevents a lower integrity process from sending window messages to a higher integrity process unless the receiving process explicitly allows UIPI. Chrome and FireFox are probably running at the same integrity level as your application. To support the drag from Internet Explorer, call ChangeWindowMessageFilter()

or ChangeWindowMessageFilterEx()

that your application receives messages WM_DROPFILES

, WM_COPYDATA

and WM_COPYGLOBALDATA

(0x0049) of processes with a lower integrity.

Update: It looks like Internet Explorer, in particular, imposes additional restrictions on drag and drop operations when it is running in Protected Mode:



How to deal with low integrity drag and drop from Internet Explorer

Understanding and Working in Internet Explorer Protected Mode - Allowing Drag and Drop Operations in the Application

+7


source







All Articles