本文主要是介绍mfc多屏检测及双击窗口最大化,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
在OnInitDialog函数中添加:
EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, NULL);
MonitorEnumProc函数:
CArray <MONITORINFO, MONITORINFO&>g_arMonitorInfo;
BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
{MONITORINFO monitorInfo = { 0 };monitorInfo.cbSize = sizeof(MONITORINFO);BOOL bRet = GetMonitorInfo(hMonitor, &monitorInfo);g_arMonitorInfo.Add(monitorInfo);return TRUE;
}
屏幕信息加载到了g_arMonitorInfo数组中。
双击标题栏,窗口最大化:
if (point.y <= 32)
{CPoint ptScreen = point;ClientToScreen(&ptScreen);int i, nSize = (int)g_arMonitorInfo.GetSize();for (i = 0; i < nSize; i++){CRect rtMonitor = g_arMonitorInfo[i].rcMonitor;if (rtMonitor.PtInRect(ptScreen)){MoveWindow(rtMonitor, TRUE);}}
}
这篇关于mfc多屏检测及双击窗口最大化的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!