qt以管理员身份运行删除无效为什么?
qt以管理员身份运行删除无效, 我在qt中使用了win32 api ChangeWindowMessageFilterEx,但不起作用, 我在MFC中使用了win32 api ChangeWindowMessageFilterEx 当我以管理员身份运行时,无法在qt中接收WM_DROPFILES消息。 这是qtqt以管理员身份运行删除无效为什么?,qt,mfc,administrator,Qt,Mfc,Administrator,qt以管理员身份运行删除无效, 我在qt中使用了win32 api ChangeWindowMessageFilterEx,但不起作用, 我在MFC中使用了win32 api ChangeWindowMessageFilterEx 当我以管理员身份运行时,无法在qt中接收WM_DROPFILES消息。 这是qt int main(int argc, char *argv[]) { QApplication a(argc, argv); DropTest w; w.show
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
DropTest w;
w.show();
CHANGEFILTERSTRUCT chfit1 = { sizeof(CHANGEFILTERSTRUCT) };
CHANGEFILTERSTRUCT chfit2 = { sizeof(CHANGEFILTERSTRUCT) };
CHANGEFILTERSTRUCT chfit3 = { sizeof(CHANGEFILTERSTRUCT) };
HWND hwnd = (HWND)w.winId();;
DragAcceptFiles(hwnd, TRUE);
DropTest::ChangeWndMessageFilterOk(hwnd, WM_DROPFILES, MSGFLT_ALLOW, &chfit1);
DropTest::ChangeWndMessageFilterOk(hwnd, WM_COPYDATA, MSGFLT_ALLOW, &chfit2);
DropTest::ChangeWndMessageFilterOk(hwnd, 0x0049, MSGFLT_ALLOW, &chfit3); // 0x0049 == WM_COPYGLOBALDATA
//MyXcbEventFilter nativeEventFilterZ;
//a.installNativeEventFilter(&nativeEventFilterZ);
return a.exec();
}
BOOL DropTest::ChangeWndMessageFilterOk(HWND hWnd, UINT nMessage, DWORD dwAction, PCHANGEFILTERSTRUCT chfit)
{
//typedef BOOL (WINAPI * ChangeWindowMessageFilterOkFn)(__in HWND hWnd, __in UINT message, __in DWORD action, __inout_opt PCHANGEFILTERSTRUCT pChangeFilterStruct);
typedef BOOL (WINAPI *ChangeWindowMessageFilterOkFn)(HWND, UINT, DWORD, PCHANGEFILTERSTRUCT);
HMODULE hModUser32 = NULL;
hModUser32 = LoadLibrary(L"user32.dll");
if (hModUser32 == NULL) {
return FALSE;
}
ChangeWindowMessageFilterOkFn pfnChangeWindowMessageFilter = (ChangeWindowMessageFilterOkFn) GetProcAddress(hModUser32, "ChangeWindowMessageFilterEx");
if (pfnChangeWindowMessageFilter == NULL)
{
FreeLibrary(hModUser32);
return FALSE;
}
FreeLibrary(hModUser32);
BOOL ret = pfnChangeWindowMessageFilter(hWnd, nMessage, dwAction, chfit);
QString strOut = QString("%1 ret = [%2] ExtStatus=[%3]\n").arg(__FUNCTION__, QString::number(ret), QString::number(chfit->ExtStatus));
OutputDebugString(strOut.toStdWString().c_str());
return ret;
}
我找到了研究报告,
使用RevokeDragDrop是可以的!
这是qt源代码
void QWindowsWindow::setDropSiteEnabled(bool dropEnabled)
{
if (isDropSiteEnabled() == dropEnabled)
return;
qCDebug(lcQpaMime) << __FUNCTION__ << window() << dropEnabled;
#if !defined(QT_NO_CLIPBOARD) && !defined(QT_NO_DRAGANDDROP)
if (dropEnabled) {
Q_ASSERT(m_data.hwnd);
m_dropTarget = new QWindowsOleDropTarget(window());
RegisterDragDrop(m_data.hwnd, m_dropTarget);
CoLockObjectExternal(m_dropTarget, true, true);
} else {
CoLockObjectExternal(m_dropTarget, false, true);
m_dropTarget->Release();
RevokeDragDrop(m_data.hwnd);
m_dropTarget = 0;
}
#endif // !QT_NO_CLIPBOARD && !QT_NO_DRAGANDDROP
}
void QWindowsWindow::setDropSiteEnabled(bool dropEnabled)
{
如果(isDropSiteEnabled()==dropEnabled)
返回;
qCDebug(lcQpaMime)我找到了研究,
使用RevokeDragDrop是可以的!
这是qt源代码
void QWindowsWindow::setDropSiteEnabled(bool dropEnabled)
{
if (isDropSiteEnabled() == dropEnabled)
return;
qCDebug(lcQpaMime) << __FUNCTION__ << window() << dropEnabled;
#if !defined(QT_NO_CLIPBOARD) && !defined(QT_NO_DRAGANDDROP)
if (dropEnabled) {
Q_ASSERT(m_data.hwnd);
m_dropTarget = new QWindowsOleDropTarget(window());
RegisterDragDrop(m_data.hwnd, m_dropTarget);
CoLockObjectExternal(m_dropTarget, true, true);
} else {
CoLockObjectExternal(m_dropTarget, false, true);
m_dropTarget->Release();
RevokeDragDrop(m_data.hwnd);
m_dropTarget = 0;
}
#endif // !QT_NO_CLIPBOARD && !QT_NO_DRAGANDDROP
}
void QWindowsWindow::setDropSiteEnabled(bool dropEnabled)
{
如果(isDropSiteEnabled()==dropEnabled)
返回;
qCDebug(lcQpaMime)您准确地收到了什么错误消息?无法接收WM_DROPFILES消息您准确地收到了什么错误消息?无法接收WM_DROPFILES消息