当前位置: 首页>>代码示例>>C++>>正文


C++ MonitorFromRect函数代码示例

本文整理汇总了C++中MonitorFromRect函数的典型用法代码示例。如果您正苦于以下问题:C++ MonitorFromRect函数的具体用法?C++ MonitorFromRect怎么用?C++ MonitorFromRect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了MonitorFromRect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AssertInsideScreen

static INT_PTR AssertInsideScreen(WPARAM wParam, LPARAM lParam)
{
	LPRECT rc = (LPRECT) wParam;
	if (rc == NULL)
		return -1;

	RECT rcScreen;
	SystemParametersInfo(SPI_GETWORKAREA, 0, &rcScreen, FALSE);

	if (MonitorFromRect(rc, MONITOR_DEFAULTTONULL))
		return 0;

	MONITORINFO mi = {0};
	HMONITOR hMonitor = MonitorFromRect(rc, MONITOR_DEFAULTTONEAREST);
	mi.cbSize = sizeof(mi);
	if (GetMonitorInfo(hMonitor, &mi))
		rcScreen = mi.rcWork;

	if (rc->top >= rcScreen.bottom)
		OffsetRect(rc, 0, rcScreen.bottom - rc->bottom);
	else if (rc->bottom <= rcScreen.top)
		OffsetRect(rc, 0, rcScreen.top - rc->top);
	if (rc->left >= rcScreen.right)
		OffsetRect(rc, rcScreen.right - rc->right, 0);
	else if (rc->right <= rcScreen.left)
		OffsetRect(rc, rcScreen.left - rc->left, 0);

	return 1;
}
开发者ID:martok,项目名称:miranda-ng,代码行数:29,代码来源:utils.cpp

示例2: clamp_window

int clamp_window(RECT *rwin)
{
	HMONITOR hmon;
	hmon=MonitorFromRect(rwin,MONITOR_DEFAULTTONEAREST);
	if(hmon){
		MONITORINFO mi;
		mi.cbSize=sizeof(mi);
		if(GetMonitorInfo(hmon,&mi)){
			int x,y,cx,cy;
			RECT rmon;
			rmon=mi.rcWork;
			x=rwin->left;
			y=rwin->top;
			cx=rwin->right-rwin->left;
			cy=rwin->bottom-rwin->top;
			if(x<rmon.left)
				x=rmon.left;
			if(y<rmon.top)
				y=rmon.top;
			if(cx>(rmon.right-rmon.left))
				cx=rmon.right-rmon.left;
			if(cy>(rmon.bottom-rmon.top))
				cy=rmon.bottom-rmon.top;
			if((x+cx)>rmon.right)
				x=rmon.right-cx;
			if((y+cy)>rmon.bottom)
				y=rmon.bottom-cy;
			rwin->left=x;
			rwin->top=y;
			rwin->right=x+cx;
			rwin->bottom=y+cy;
		}
	}
	return 0;
}
开发者ID:pinchyCZN,项目名称:ini_compare,代码行数:35,代码来源:ini_file.c

示例3: GetBestOverlapWithMonitors

void GetBestOverlapWithMonitors(LPRECT rect)
{
    int rcLeft, rcTop;
    int rcWidth, rcHeight;
    RECT rcMon;
    HMONITOR hMon = MonitorFromRect(rect, MONITOR_DEFAULTTONEAREST);
    MONITORINFO info;
    info.cbSize = sizeof(info);

    GetMonitorInfo(hMon, &info);

    rcMon = info.rcMonitor;

    rcLeft = rect->left;
    rcTop = rect->top;
    rcWidth  = (rect->right - rect->left);
    rcHeight = (rect->bottom - rect->top);

    if (rcLeft < rcMon.left)
       rcLeft = rcMon.left;

    if (rcTop < rcMon.top)
       rcTop = rcMon.top;

    if (rcLeft > (rcMon.right - rcWidth))
        rcLeft = (rcMon.right - rcWidth);

    if (rcTop > (rcMon.bottom - rcHeight))
        rcTop = (rcMon.bottom - rcHeight);

    OffsetRect(rect, (rcLeft-rect->left), (rcTop-rect->top));
}
开发者ID:amaneureka,项目名称:reactos,代码行数:32,代码来源:magnifier.c

示例4: PhSaveWindowPlacementToSetting

VOID PhSaveWindowPlacementToSetting(
    _In_opt_ PWSTR PositionSettingName,
    _In_opt_ PWSTR SizeSettingName,
    _In_ HWND WindowHandle
    )
{
    WINDOWPLACEMENT placement = { sizeof(placement) };
    PH_RECTANGLE windowRectangle;
    MONITORINFO monitorInfo = { sizeof(MONITORINFO) };

    GetWindowPlacement(WindowHandle, &placement);
    windowRectangle = PhRectToRectangle(placement.rcNormalPosition);

    // The rectangle is in workspace coordinates. Convert the values back to screen coordinates.
    if (GetMonitorInfo(MonitorFromRect(&placement.rcNormalPosition, MONITOR_DEFAULTTOPRIMARY), &monitorInfo))
    {
        windowRectangle.Left += monitorInfo.rcWork.left - monitorInfo.rcMonitor.left;
        windowRectangle.Top += monitorInfo.rcWork.top - monitorInfo.rcMonitor.top;
    }

    if (PositionSettingName)
        PhSetIntegerPairSetting(PositionSettingName, windowRectangle.Position);
    if (SizeSettingName)
        PhSetScalableIntegerPairSetting2(SizeSettingName, windowRectangle.Size);
}
开发者ID:poizan42,项目名称:processhacker2,代码行数:25,代码来源:settings.c

示例5: reopen_console

void reopen_console (void)
{
	HWND hwnd;

	if (realconsole)
		return;
	if (consoleopen >= 0)
		return;
	hwnd = myGetConsoleWindow ();
	if (hwnd) {
		int newpos = 1;
		int x, y, w, h;
		if (!regqueryint (NULL, _T("LoggerPosX"), &x))
			newpos = 0;
		if (!regqueryint (NULL, _T("LoggerPosY"), &y))
			newpos = 0;
		if (!regqueryint (NULL, _T("LoggerPosW"), &w))
			newpos = 0;
		if (!regqueryint (NULL, _T("LoggerPosH"), &h))
			newpos = 0;
		if (newpos) {
			RECT rc;
			rc.left = x;
			rc.top = y;
			rc.right = x + w;
			rc.bottom = y + h;
			if (MonitorFromRect (&rc, MONITOR_DEFAULTTONULL) != NULL) {
				SetForegroundWindow (hwnd);
				SetWindowPos (hwnd, HWND_TOP, x, y, w, h, SWP_NOACTIVATE);

			}
		}
	}
}
开发者ID:biglad,项目名称:WinUAE,代码行数:34,代码来源:writelog.cpp

示例6: bar

bool grib_pi::QualifyCtrlBarPosition( wxPoint position, wxSize size )
{   // Make sure drag bar (title bar) or grabber always screen
    bool b_reset_pos = false;
#ifdef __WXMSW__
    //  Support MultiMonitor setups which an allow negative window positions.
    //  If the requested window does not intersect any installed monitor,
    //  then default to simple primary monitor positioning.
    RECT frame_title_rect;
    frame_title_rect.left =  position.x;
    frame_title_rect.top =    position.y;
    frame_title_rect.right =  position.x + size.x;
    frame_title_rect.bottom = m_DialogStyle == ATTACHED_HAS_CAPTION ? position.y + 30 : position.y + size.y;


    if(NULL == MonitorFromRect(&frame_title_rect, MONITOR_DEFAULTTONULL))
        b_reset_pos = true;
#else
    wxRect window_title_rect;                    // conservative estimate
    window_title_rect.x = position.x;
    window_title_rect.y = position.y;
    window_title_rect.width = size.x;
    window_title_rect.height = m_DialogStyle == ATTACHED_HAS_CAPTION ? 30 : size.y;

    wxRect ClientRect = wxGetClientDisplayRect();
    if(!ClientRect.Intersects(window_title_rect))
        b_reset_pos = true;

#endif
    return !b_reset_pos;
}
开发者ID:vregnard,项目名称:OpenCPN,代码行数:30,代码来源:grib_pi.cpp

示例7: hippo_platform_impl_get_screen_info

static void
hippo_platform_impl_get_screen_info(HippoPlatform     *platform,
                                    HippoRectangle    *monitor_rect_p,
                                    HippoRectangle    *tray_icon_rect_p,
                                    HippoOrientation  *tray_icon_orientation_p)
{
    APPBARDATA abd;
    abd.cbSize = sizeof(abd);
    if (!SHAppBarMessage(ABM_GETTASKBARPOS, &abd)) {
        g_warning("Failed to get task bar extents");
        return;
    }

    HippoOrientation orientation;
    switch (abd.uEdge) {
        case ABE_BOTTOM:
        case ABE_TOP:
            orientation = HIPPO_ORIENTATION_HORIZONTAL;
            break;
        case ABE_LEFT:
        case ABE_RIGHT:
            orientation = HIPPO_ORIENTATION_VERTICAL;
            break;
        default:
            g_warning("unknown tray icon orientation");
            break;
    }

    if (tray_icon_orientation_p)
        *tray_icon_orientation_p = orientation;

    RECT iconTrayRect;

    if (!find_icon_tray_rect(&iconTrayRect, orientation)) {
        // If this starts happening  regularly, we can refine
        // this code to make a better guess at that point.
        iconTrayRect = abd.rc;
    }

    if (tray_icon_rect_p) {
        tray_icon_rect_p->x = iconTrayRect.left;
        tray_icon_rect_p->width = iconTrayRect.right - iconTrayRect.left;
        tray_icon_rect_p->y = iconTrayRect.top;
        tray_icon_rect_p->height = iconTrayRect.bottom - iconTrayRect.top;
    }

    if (monitor_rect_p) {
        HMONITOR monitor = MonitorFromRect(&iconTrayRect, MONITOR_DEFAULTTONEAREST);
        MONITORINFO monitorInfo;
        monitorInfo.cbSize = sizeof(monitorInfo);
        if (GetMonitorInfo(monitor, &monitorInfo)) {
            monitor_rect_p->x = monitorInfo.rcWork.left;
            monitor_rect_p->y = monitorInfo.rcWork.top;
            monitor_rect_p->width = monitorInfo.rcWork.right - monitorInfo.rcWork.left;
            monitor_rect_p->height = monitorInfo.rcWork.bottom - monitorInfo.rcWork.top;
        } else {
            g_warning("GetMonitorInfo failed"); // Shouldn't happen, don't both with a fallback
        }
    }
}
开发者ID:nihed,项目名称:magnetism,代码行数:60,代码来源:HippoPlatformImpl.cpp

示例8: MonitorFromPoint

/***********************************************************************
 *		MonitorFromPoint ([email protected])
 */
HMONITOR WINAPI MonitorFromPoint( POINT pt, DWORD flags )
{
    RECT rect;

    SetRect( &rect, pt.x, pt.y, pt.x + 1, pt.y + 1 );
    return MonitorFromRect( &rect, flags );
}
开发者ID:kholia,项目名称:wine,代码行数:10,代码来源:misc.c

示例9: ResizeTo

void ResizeTo(HWND hwnd, int width, int height) {
	 HWND root_wnd = ::GetAncestor(hwnd, GA_ROOT);

  // Retrieve current window placement information.
  WINDOWPLACEMENT placement;
  ::GetWindowPlacement(root_wnd, &placement);

  if(placement.showCmd == SW_MAXIMIZE)
	  return;

  HMONITOR monitor = MonitorFromRect(&placement.rcNormalPosition,
                                     MONITOR_DEFAULTTONEAREST);
  MONITORINFO info;
  info.cbSize = sizeof(info);
  GetMonitorInfo(monitor, &info);

  if (width < 100)
    width = 100;
  else if (width > info.rcWork.right - info.rcWork.left)
	  width = info.rcWork.right - info.rcWork.left;
  if (height < 100)
	  height = 100;
  else if (height > info.rcWork.bottom - info.rcWork.top)
    height = info.rcWork.bottom - info.rcWork.top;

  ::SetWindowPos(root_wnd, NULL, 0, 0, width, height, SWP_NOMOVE | SWP_NOZORDER);
  if (placement.showCmd == SW_MINIMIZE)
    ::ShowWindow(root_wnd, SW_RESTORE);
}
开发者ID:623442733,项目名称:cef3-windows-sample,代码行数:29,代码来源:cefclient_extensions_window_win.cpp

示例10: MonitorFromWindow

/***********************************************************************
 *		MonitorFromWindow ([email protected])
 */
HMONITOR WINAPI MonitorFromWindow(HWND hWnd, DWORD dwFlags)
{
    RECT rect;
    WINDOWPLACEMENT wp;

    TRACE("(%p, 0x%08x)\n", hWnd, dwFlags);

    if (IsIconic(hWnd) && GetWindowPlacement(hWnd, &wp))
        return MonitorFromRect( &wp.rcNormalPosition, dwFlags );

    if (GetWindowRect( hWnd, &rect ))
        return MonitorFromRect( &rect, dwFlags );

    if (!(dwFlags & (MONITOR_DEFAULTTOPRIMARY|MONITOR_DEFAULTTONEAREST))) return 0;
    /* retrieve the primary */
    SetRect( &rect, 0, 0, 1, 1 );
    return MonitorFromRect( &rect, dwFlags );
}
开发者ID:kholia,项目名称:wine,代码行数:21,代码来源:misc.c

示例11: GetWorkAreaRect

RectI GetWorkAreaRect(RectI rect)
{
    MONITORINFO mi = { 0 };
    mi.cbSize = sizeof mi;
    HMONITOR monitor = MonitorFromRect(&rect.ToRECT(), MONITOR_DEFAULTTONEAREST);
    BOOL ok = GetMonitorInfo(monitor, &mi);
    if (!ok)
        SystemParametersInfo(SPI_GETWORKAREA, 0, &mi.rcWork, 0);
    return RectI::FromRECT(mi.rcWork);
}
开发者ID:Erls-Corporation,项目名称:SumatraPDF-2.2.1,代码行数:10,代码来源:WinUtil.cpp

示例12: GetMonitorInformation

MONITORINFO GetMonitorInformation(HWND handle) {
  HMONITOR monitor;
  MONITORINFO mi;
  RECT rect;
  GetWindowRect(handle, &rect);
  monitor = MonitorFromRect(&rect, MONITOR_DEFAULTTONEAREST);
  mi.cbSize = sizeof mi;
  GetMonitorInfo(monitor, &mi);
  return mi;
}
开发者ID:276361270,项目名称:hex,代码行数:10,代码来源:customized_win.cpp

示例13: sizeof

CRect CCherryNotificationDialog::GetAnchorRect(UINT nWidth, UINT nHeight)
{
	CRect rect;

	APPBARDATA appBarData;
	appBarData.cbSize = sizeof(APPBARDATA);

	if (!SHAppBarMessage(ABM_GETTASKBARPOS, &appBarData))
		return rect;

	// TASKBAR 가 위치한 모니터의 핸들 얻어옴
	HMONITOR hMonitor = MonitorFromRect(&appBarData.rc, MONITOR_DEFAULTTOPRIMARY);

	MONITORINFO monitorInfo;
	monitorInfo.cbSize = sizeof(MONITORINFO);

	GetMonitorInfo(hMonitor, &monitorInfo);
	CRect workRect(monitorInfo.rcWork);

	CPoint point;

	switch (appBarData.uEdge)
	{
	case ABE_LEFT:
		rect.SetRect(
			appBarData.rc.right,
			appBarData.rc.bottom - SCROLLBAR_WIDTH - nHeight,
			appBarData.rc.right + nWidth,
			appBarData.rc.bottom - SCROLLBAR_WIDTH);
		break;
	case ABE_TOP:
		rect.SetRect(
			appBarData.rc.right - SCROLLBAR_WIDTH - nWidth,
			appBarData.rc.bottom,
			appBarData.rc.right - SCROLLBAR_WIDTH,
			appBarData.rc.bottom + nHeight);
		break;
	case ABE_RIGHT:
		rect.SetRect(
			appBarData.rc.left - nWidth,
			appBarData.rc.bottom - SCROLLBAR_WIDTH - nHeight,
			appBarData.rc.left,
			appBarData.rc.bottom - SCROLLBAR_WIDTH);
		break;
	case ABE_BOTTOM:
		rect.SetRect(
			appBarData.rc.right - SCROLLBAR_WIDTH - nWidth,
			appBarData.rc.top - nHeight,
			appBarData.rc.right - SCROLLBAR_WIDTH,
			appBarData.rc.top);
		break;
	}

	return rect;
}
开发者ID:ogoons,项目名称:CherryLib,代码行数:55,代码来源:CherryNotificationDialog.cpp

示例14: set_window_pos

int set_window_pos(HWND hwnd,int x,int y,int w,int h,int max)
{
	int result=FALSE;
	HMONITOR hmon;
	MONITORINFO mi;
	RECT rect;
	rect.left=x;
	rect.top=y;
	rect.right=x+w;
	rect.bottom=y+h;
	hmon=MonitorFromRect(&rect,MONITOR_DEFAULTTONEAREST);
	mi.cbSize=sizeof(mi);
	if(GetMonitorInfo(hmon,&mi)){
		int cw,ch;
		rect=mi.rcWork;
		cw=w;
		ch=h;
		if(0==cw)
			cw=100;
		if(0==ch)
			ch=100;
		if((x+cw)>rect.right)
			x=rect.right-cw;
		if(x<rect.left)
			x=rect.left;
		if((y+ch)>rect.bottom)
			y=rect.bottom-ch;
		if(y<rect.top)
			y=rect.top;
		if(w>0 && h>0){
			int rw,rh;
			rw=rect.right-rect.left;
			rh=rect.bottom-rect.top;
			if(w>rw)
				w=rw;
			if(h>rh)
				h=rh;
			if(w<25)
				w=25;
			if(h<25)
				h=25;
		}
		{
			int flags=SWP_NOZORDER;
			if(max)
				flags|=SW_MAXIMIZE;
			if(w==0 || h==0)
				flags|=SWP_NOSIZE;
			SetWindowPos(hwnd,NULL,x,y,w,h,flags);
		}
		result=TRUE;
	}
	return result;
}
开发者ID:pinchyCZN,项目名称:win32shadertoy,代码行数:54,代码来源:window.c

示例15: GetMonitorBoundsForRect

gfx::Rect GetMonitorBoundsForRect(const gfx::Rect& rect)
{
    RECT p_rect = rect.ToRECT();
    HMONITOR monitor = MonitorFromRect(&p_rect, MONITOR_DEFAULTTONEAREST);
    if(monitor)
    {
        MONITORINFO mi = { 0 };
        mi.cbSize = sizeof(mi);
        GetMonitorInfo(monitor, &mi);
        return gfx::Rect(mi.rcWork);
    }
    NOTREACHED();
    return gfx::Rect();
}
开发者ID:leer168,项目名称:x-framework,代码行数:14,代码来源:monitor_win.cpp


注:本文中的MonitorFromRect函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。