Nominate our 2022 Qt Champions!

Drag and drop not working on run as administrator



  • Hi all .. why drag and drop is not working in qml when we running application as administrator mode .. any solution .. to workaround for it .. one solution to modify registry key value 'EnableLUA' to 0 it is working but i don't want to modify registry .


  • Lifetime Qt Champion

    Hi
    If you are talking about windows OS, its due to the fact that
    administrator is run in another security context.
    https://superuser.com/questions/59051/drag-and-drop-file-into-application-under-run-as-administrator

    You try ( while running the app as adim)
    launch cmd (Command Prompt) using Run As Administrator

    Type:
    taskkill /f /im explorer.exe
    start explorer.exe

    Then try to drag to your app and see if that makes any difference.

    This is not isolated to Qt apps. btw.



  • What I'm trying to say is that only QT has this problem! ! !

    call the following function
    // application
    ::ChangeWindowMessageFilter(WM_DROPFILES, MSGFLT_ADD);
    ::ChangeWindowMessageFilter(WM_COPYDATA, MSGFLT_ADD);
    ::ChangeWindowMessageFilter(WM_COPYGLOBALDATA, MSGFLT_ADD);

    // window
    ::DragAcceptFiles(HWND, TRUE);
    ::ChangeWindowMessageFilterEx(HWND, WM_DROPFILES, MSGFLT_ALLOW, nullptr);
    ::ChangeWindowMessageFilterEx(HWND, WM_COPYDATA, MSGFLT_ALLOW, nullptr);
    ::ChangeWindowMessageFilterEx(HWND, WM_COPYGLOBALDATA, MSGFLT_ALLOW, nullptr);
    When I use MFC, Win32, wxWidgets, there is no problem.

    Only QT, called and nothing happens.
    I don't understand, why my use of WinId doesn't work.
    How exactly is it different from the HWND returned by CreateWindow?
    Or, what is QT doing internally that causes these calls to fail.


Log in to reply