本文整理汇总了C++中MonitorFromWindow函数的典型用法代码示例。如果您正苦于以下问题:C++ MonitorFromWindow函数的具体用法?C++ MonitorFromWindow怎么用?C++ MonitorFromWindow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MonitorFromWindow函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetWindowPlacement
void ViewerWindow::setSizeFullScreenWindow()
{
// Save position of window.
GetWindowPlacement(m_hWnd, &m_workArea);
// Get size of desktop.
HMONITOR hmon = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
MONITORINFO mi;
mi.cbSize = sizeof(mi);
RECT fullScreenWindowsRect;
if (!!GetMonitorInfo(hmon, &mi)) {
fullScreenWindowsRect = mi.rcMonitor;
}
else {
m_logWriter.warning(_T("Get monitor info is failed. Use second method (no multi-screen)."));
GetWindowRect(GetDesktopWindow(), &fullScreenWindowsRect);
}
Rect fullScreenRect;
fullScreenRect.fromWindowsRect(&fullScreenWindowsRect);
m_logWriter.detail(_T("full screen window rect: %d, %d; %d, %d"),
fullScreenRect.left, fullScreenRect.top,
fullScreenRect.getWidth(), fullScreenRect.getHeight());
setStyle((getStyle() | WS_MAXIMIZE) & ~(WS_CAPTION | WS_BORDER | WS_THICKFRAME | WS_MAXIMIZEBOX));
setExStyle(getExStyle() | WS_EX_TOPMOST);
SetWindowPos(m_hWnd, 0,
fullScreenRect.left, fullScreenRect.top,
fullScreenRect.getWidth(), fullScreenRect.getHeight(),
SWP_SHOWWINDOW);
}
示例2: Manage
static void Manage(vout_display_t *vd)
{
vout_display_sys_t *sys = vd->sys;
CommonManage(vd);
if (sys->changes & DX_POSITION_CHANGE) {
/* Update overlay */
if (sys->use_overlay)
DirectXUpdateOverlay(vd, NULL);
/* Check if we are still on the same monitor */
HMONITOR hmon = MonitorFromWindow(sys->hwnd, MONITOR_DEFAULTTONEAREST);
if (sys->hmonitor != hmon) {
vout_display_SendEventPicturesInvalid(vd);
}
/* */
sys->changes &= ~DX_POSITION_CHANGE;
}
/* Wallpaper mode change */
vlc_mutex_lock(&sys->lock);
const bool ch_wallpaper = sys->ch_wallpaper;
const bool wallpaper_requested = sys->wallpaper_requested;
sys->ch_wallpaper = false;
vlc_mutex_unlock(&sys->lock);
if (ch_wallpaper)
WallpaperChange(vd, wallpaper_requested);
/* */
if (sys->restore_overlay)
DirectXUpdateOverlay(vd, NULL);
}
示例3: SetRect
void D3D9RenderWindow::adjustWindow(unsigned int clientWidth, unsigned int clientHeight,
unsigned int* winWidth, unsigned int* winHeight)
{
// NB only call this for non full screen
RECT rc;
SetRect(&rc, 0, 0, clientWidth, clientHeight);
AdjustWindowRect(&rc, WS_VISIBLE | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW, false);
*winWidth = rc.right - rc.left;
*winHeight = rc.bottom - rc.top;
// adjust to monitor
HMONITOR hMonitor = MonitorFromWindow(mHWnd, MONITOR_DEFAULTTONEAREST);
// Get monitor info
MONITORINFO monitorInfo;
memset(&monitorInfo, 0, sizeof(MONITORINFO));
monitorInfo.cbSize = sizeof(MONITORINFO);
GetMonitorInfo(hMonitor, &monitorInfo);
LONG maxW = monitorInfo.rcWork.right - monitorInfo.rcWork.left;
LONG maxH = monitorInfo.rcWork.bottom - monitorInfo.rcWork.top;
if (*winWidth > (unsigned int)maxW)
*winWidth = maxW;
if (*winHeight > (unsigned int)maxH)
*winHeight = maxH;
}
示例4: MonitorFromWindow
BOOL CMonitorManager::GetMonitorResolution(HWND hWnd, long *lResoluteW, long *lResoluteH)
{
HMONITOR hm = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
BOOL bFindMonitor = FALSE;
for(int i = 0; i < m_MonitorList.size(); i++)
{
if (hm == m_MonitorList[i].hMonitor)
{
bFindMonitor = TRUE;
break;
}
}
if (!bFindMonitor) return FALSE;
DISPLAY_DEVICE dd;
ZeroMemory(&dd, sizeof(DISPLAY_DEVICE));
dd.cb = sizeof(DISPLAY_DEVICE);
bFindMonitor = EnumDisplayDevices(NULL, i, &dd, 0);
if (!bFindMonitor) return FALSE;
DEVMODE dm;
ZeroMemory(&dm, sizeof(DEVMODE));
dm.dmSize = sizeof(dm);
bFindMonitor = EnumDisplaySettings((char*)dd.DeviceName, ENUM_CURRENT_SETTINGS, &dm);
if (!bFindMonitor) return FALSE;
*lResoluteW = dm.dmPelsWidth;
*lResoluteH = dm.dmPelsHeight;
return TRUE;
}
示例5: d3d_free
static void d3d_free(void *data)
{
d3d_video_t *d3d = (d3d_video_t*)data;
d3d_deinitialize(d3d);
#ifdef _XBOX
if (d3d->ctx_driver && d3d->ctx_driver->destroy)
d3d->ctx_driver->destroy(d3d);
d3d->ctx_driver = NULL;
#endif
if (d3d->dev)
d3d->dev->Release();
if (d3d->g_pD3D)
d3d->g_pD3D->Release();
#ifdef HAVE_MONITOR
Monitor::last_hm = MonitorFromWindow(d3d->hWnd, MONITOR_DEFAULTTONEAREST);
DestroyWindow(d3d->hWnd);
#endif
if (d3d)
delete d3d;
#ifndef _XBOX
UnregisterClass("RetroArch", GetModuleHandle(NULL));
#endif
}
示例6: gfx_ctx_destroy
static void gfx_ctx_destroy(void)
{
if (g_hrc)
{
wglMakeCurrent(NULL, NULL);
wglDeleteContext(g_hrc);
g_hrc = NULL;
}
if (g_hwnd && g_hdc)
{
ReleaseDC(g_hwnd, g_hdc);
g_hdc = NULL;
}
if (g_hwnd)
{
g_last_hm = MonitorFromWindow(g_hwnd, MONITOR_DEFAULTTONEAREST);
DestroyWindow(g_hwnd);
UnregisterClass("RetroArch", GetModuleHandle(NULL));
g_hwnd = NULL;
}
if (g_restore_desktop)
{
MONITORINFOEX current_mon;
memset(¤t_mon, 0, sizeof(current_mon));
current_mon.cbSize = sizeof(MONITORINFOEX);
GetMonitorInfo(g_last_hm, (MONITORINFO*)¤t_mon);
ChangeDisplaySettingsEx(current_mon.szDevice, NULL, NULL, 0, NULL);
g_restore_desktop = false;
}
g_inited = false;
}
示例7: sizeof
void ConfigFileManager::CreateInstallerWindow(const std::wstring& title)
{
if (m_pInstallerWindow != NULL)
{
delete m_pInstallerWindow;
m_pInstallerWindow = NULL;
}
MONITORINFO mi = { 0 };
mi.cbSize = sizeof(mi);
CHECK_WIN32_BOOL(GetMonitorInfo(MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY), & mi),
L"GetMonitorInfo");
int cx = 640;
int cy = 480;
m_pInstallerWindow = new InstallerWindow(); // deletes itself
m_pInstallerWindow->Create(
(mi.rcWork.left + mi.rcWork.right) / 2 - cx / 2,
(mi.rcWork.top + mi.rcWork.bottom) / 2 - cy / 2,
cx, cy, title.c_str());
CHECK_BOOL(m_pInstallerWindow->hwnd != NULL,
L"InstallerWindow::Create");
}
示例8: SetWindowMode
static void
SetWindowMode(window_data Data, int Width, int Height)
{
MONITORINFO MonitorInfo = {};
MonitorInfo.cbSize = sizeof(MonitorInfo);
if(GetMonitorInfo(MonitorFromWindow(Data.Window, MONITOR_DEFAULTTONEAREST), &MonitorInfo)) {
RECT Rect = MonitorInfo.rcMonitor;
int MonitorWidth = Rect.right - Rect.left;
int MonitorHeight = Rect.bottom - Rect.top;
int X = Rect.left;
int Y = Rect.top;
if(MonitorWidth > Width) {
X = (MonitorWidth - Width) / 2;
}
if(MonitorHeight > Height) {
Y = (MonitorHeight - Height) / 2;
}
SetWindowDimensions(Data, X, Y, Width, Height);
}
else {
PRINT_ERR("Could not get monitor info.\n");
}
SetBorderlessWindowStyle(Data);
}
示例9: MonitorFromWindow
void WindowManager::toggleBorderlessFullscreen() {
borderlessFullscreen = !borderlessFullscreen;
HWND hwnd = ::GetActiveWindow();
if(borderlessFullscreen) {
// store previous rect
::GetClientRect(hwnd, &prevWindowRect);
// set styles
LONG lStyle = ::GetWindowLong(hwnd, GWL_STYLE);
prevStyle = lStyle;
lStyle &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU);
::SetWindowLong(hwnd, GWL_STYLE, lStyle);
LONG lExStyle = ::GetWindowLong(hwnd, GWL_EXSTYLE);
prevExStyle = lExStyle;
lExStyle &= ~(WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE);
::SetWindowLong(hwnd, GWL_EXSTYLE, lExStyle);
// adjust size & position
HMONITOR monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
MONITORINFO info;
info.cbSize = sizeof(MONITORINFO);
GetMonitorInfo(monitor, &info);
int monitorWidth = info.rcMonitor.right - info.rcMonitor.left;
int monitorHeight = info.rcMonitor.bottom - info.rcMonitor.top;
::SetWindowPos(hwnd, NULL, info.rcMonitor.left, info.rcMonitor.top, monitorWidth, monitorHeight, SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOOWNERZORDER);
} else {
// restore previous window
::SetWindowLong(hwnd, GWL_STYLE, prevStyle);
::SetWindowLong(hwnd, GWL_EXSTYLE, prevExStyle);
RECT desiredRect = prevWindowRect;
::AdjustWindowRect(&desiredRect, prevStyle, false);
int wWidth = desiredRect.right - desiredRect.left, wHeight = desiredRect.bottom - desiredRect.top;
::SetWindowPos(hwnd, NULL, prevWindowRect.left, prevWindowRect.top, wWidth, wHeight, SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOOWNERZORDER);
}
}
示例10: Win32FullscreenToggle
// Thank you Raymond Chen!!
void Win32FullscreenToggle(HWND window)
{
DWORD style = GetWindowLong(window, GWL_STYLE);
if (style & WS_OVERLAPPEDWINDOW)
{
MONITORINFO monitorInfo = { sizeof(monitorInfo) };
if (GetWindowPlacement(window, &globalWindowPos) &&
GetMonitorInfo(MonitorFromWindow(window, MONITOR_DEFAULTTOPRIMARY), &monitorInfo))
{//NOT BITWISE OPERATOR
SetWindowLong(window, GWL_STYLE, style & ~WS_OVERLAPPEDWINDOW);
SetWindowPos(window, HWND_TOP,
monitorInfo.rcMonitor.left, monitorInfo.rcMonitor.top,
monitorInfo.rcMonitor.right - monitorInfo.rcMonitor.left,
monitorInfo.rcMonitor.bottom - monitorInfo.rcMonitor.top,
SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
}
}
else
{
SetWindowLong(window, GWL_STYLE, style | WS_OVERLAPPEDWINDOW);
SetWindowPlacement(window, &globalWindowPos);
SetWindowPos(window, NULL, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
}
}
示例11: MonitorFromWindow
void DXContext::MinimizeWinamp(HMONITOR hPluginMonitor)
{
// minimize Winamp window
HMONITOR hWinampMon = MonitorFromWindow(m_hwnd_winamp, MONITOR_DEFAULTTONEAREST);
HMONITOR hPluginMon = hPluginMonitor;//MonitorFromWindow(m_hwnd, MONITOR_DEFAULTTONEAREST);//m_lpD3D->GetAdapterMonitor(ordinal_adapter);
if ((m_current_mode.screenmode == FULLSCREEN || m_current_mode.screenmode == FAKE_FULLSCREEN) &&
(m_minimize_winamp) &&
(hWinampMon && hPluginMon && hPluginMon==hWinampMon) &&
(!m_winamp_minimized)
)
{
// nitpicky check: if we're in fake fullscreen mode
// and are only going to display on half the screen,
// don't minimize Winamp.
if (m_current_mode.screenmode == FAKE_FULLSCREEN)
{
int x = m_monitor_rect.right - m_monitor_rect.left;
int y = m_monitor_rect.bottom - m_monitor_rect.top;
if ((x >= y*2 && m_current_mode.m_dualhead_horz != 0) ||
(y > x*4/3 && m_current_mode.m_dualhead_vert != 0))
{
return;
}
}
ShowWindow(m_hwnd_winamp, SW_MINIMIZE);
// also restore the focus to the plugin window, since this will steal it:
SetFocus(m_hwnd);
SetActiveWindow(m_hwnd);
SetForegroundWindow(m_hwnd);
m_winamp_minimized = 1;
}
}
示例12: MonitorFromWindow
bool D3D9Device::validateDisplayMonitor(D3D9RenderWindowCore* renderWindow)
{
// Ignore full screen since it doesn't really move and it is possible
// that it created using multi-head adapter so for a subordinate the
// native monitor handle and this device handle will be different.
if (renderWindow->getProperties().isFullScreen())
return true;
HMONITOR hRenderWindowMonitor = NULL;
// Find the monitor this render window belongs to.
hRenderWindowMonitor = MonitorFromWindow(renderWindow->_getWindowHandle(), MONITOR_DEFAULTTONULL);
// This window doesn't intersect with any of the display monitor
if (hRenderWindowMonitor == NULL)
return false;
// Case this window changed monitor.
if (hRenderWindowMonitor != mMonitor)
{
// Lock access to rendering device.
D3D9RenderAPI::getResourceManager()->lockDeviceAccess();
mpDeviceManager->linkRenderWindow(renderWindow);
// UnLock access to rendering device.
D3D9RenderAPI::getResourceManager()->unlockDeviceAccess();
return false;
}
return true;
}
示例13: CorrectConsolePos
void CorrectConsolePos(HWND hConWnd)
{
RECT rcNew = {};
if (GetWindowRect(hConWnd, &rcNew))
{
HMONITOR hMon = MonitorFromWindow(hConWnd, MONITOR_DEFAULTTOPRIMARY);
MONITORINFO mi = {sizeof(mi)};
//int nMaxX = 0, nMaxY = 0;
if (GetMonitorInfo(hMon, &mi))
{
int newW = (rcNew.right-rcNew.left), newH = (rcNew.bottom-rcNew.top);
int newX = rcNew.left, newY = rcNew.top;
if (newX < mi.rcWork.left)
newX = mi.rcWork.left;
else if (rcNew.right > mi.rcWork.right)
newX = max(mi.rcWork.left,(mi.rcWork.right-newW));
if (newY < mi.rcWork.top)
newY = mi.rcWork.top;
else if (rcNew.bottom > mi.rcWork.bottom)
newY = max(mi.rcWork.top,(mi.rcWork.bottom-newH));
if ((newX != rcNew.left) || (newY != rcNew.top))
SetWindowPos(hConWnd, HWND_TOP, newX, newY,0,0, SWP_NOSIZE);
}
}
}
示例14: SystemParametersInfo
void Dialog::SnapToEdges(LPWINDOWPOS window_pos) {
if (!snap_gap_)
return;
RECT rc_monitor = {0};
SystemParametersInfo(SPI_GETWORKAREA, 0, &rc_monitor, 0);
if (GetSystemMetrics(SM_CMONITORS) > 1) {
HMONITOR monitor = MonitorFromWindow(window_, MONITOR_DEFAULTTONEAREST);
if (monitor) {
MONITORINFO mi;
mi.cbSize = sizeof(mi);
GetMonitorInfo(monitor, &mi);
rc_monitor = mi.rcWork;
}
}
// Snap X axis
if (abs(window_pos->x - rc_monitor.left) <= snap_gap_) {
window_pos->x = rc_monitor.left;
} else if (abs(window_pos->x + window_pos->cx - rc_monitor.right) <= snap_gap_) {
window_pos->x = rc_monitor.right - window_pos->cx;
}
// Snap Y axis
if (abs(window_pos->y - rc_monitor.top) <= snap_gap_) {
window_pos->y = rc_monitor.top;
} else if (abs(window_pos->y + window_pos->cy - rc_monitor.bottom) <= snap_gap_) {
window_pos->y = rc_monitor.bottom - window_pos->cy;
}
}
示例15: MonitorFromWindow
void CDpiAware::GetCenteredRect(HWND hWnd, RECT& rcCentered, HMONITOR hDefault /*= NULL*/)
{
bool lbCentered = false;
HMONITOR hMon;
if (hWnd)
hMon = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
else
hMon = MonitorFromRect(&rcCentered, MONITOR_DEFAULTTONEAREST);
MONITORINFO mi = {};
GetNearestMonitorInfo(&mi, hDefault, hWnd ? NULL : &rcCentered, hWnd);
int iWidth = rcCentered.right - rcCentered.left;
int iHeight = rcCentered.bottom - rcCentered.top;
RECT rcNew = {
(mi.rcWork.left + mi.rcWork.right - iWidth)/2,
(mi.rcWork.top + mi.rcWork.bottom - iHeight)/2
};
rcNew.right = rcNew.left + iWidth;
rcNew.bottom = rcNew.top + iHeight;
rcCentered = rcNew;
}