Le Giap 2009-09-29 15:53
Hi, I have a problem. I have two monitors. When i plug-out a monitor, applications on that monitor wil be disable.
But, i cant not catching window message when i unplug monitor. I using VS.2003.
I catch on WM_DEVICECHANGE message. It always return DISPLAY_DEVICE_ATTACHED_TO_DESKTOP.
Can you help fix solution. My code
DISPLAY_DEVICE dd; ZeroMemory(&dd, sizeof(dd)); dd.cb = sizeof(dd);
EnumDisplayDevices(0, 1, &dd, 0);
if (!(dd.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER)) { DISPLAY_DEVICE ddMon; ZeroMemory(&ddMon, sizeof(ddMon)); ddMon.cb = sizeof(ddMon); DWORD devMon = 0;
while (EnumDisplayDevices(dd.DeviceName, devMon, &ddMon, 0)) { if (ddMon.StateFlags & DISPLAY_DEVICE_ACTIVE) break; devMon++; } if (!*ddMon.DeviceString) { EnumDisplayDevices(dd.DeviceName, 0, &ddMon, 0); if (!*ddMon.DeviceString) lstrcpy(ddMon.DeviceString, _T("Default Monitor")); } if(!(ddMon.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)) { this->ShowWindow(SW_HIDE); } else { this->ShowWindow(SW_SHOW); } } return CDialog::OnDeviceChange(nEventType,dwData); }
|