Re -load the NativeEvent method in QwidGT, but cannot receive DBT_DEVICEARIVAL and DBT_DEVICEREMOVECOMPLETE messages
MSG* msg = reinterpret_cast<MSG*>(pMessage);
auto wParam = msg->wParam;
if (wParam == DBT_DEVICEARRIVAL || wParam == DBT_DEVICEREMOVECOMPLETE) {
auto lParam = msg->lParam;
auto deviceType = reinterpret_cast<DEV_BROADCAST_HDR *>(lParam)->dbch_devicetype;
if (deviceType == DBT_DEVTYP_VOLUME) {
auto unitmask = reinterpret_cast<DEV_BROADCAST_VOLUME *>(lParam)->dbcv_unitmask;
for (int i = 0; i < 32; ++i) {
if ((unitmask & (1 << i)) != 0) {
// setDriveChanged(‘A’ + i, wParam == DBT_DEVICEARRIVAL);
}
}
}
}
return false;
After investigation, it is found that the current Widget is a sub -window. NativeEvent can only receive Windows system messages only when Nativa Windows, so it is necessary to process USB related events in the Native window.