• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ MonitorFromPoint函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: GetStartupMonitor

// If possible, open our windows on the monitor where user
// have clicked our icon (shortcut on the desktop or TaskBar)
HMONITOR GetStartupMonitor()
{
	STARTUPINFO si = {sizeof(si)};
	MONITORINFO mi = {sizeof(mi)};
	POINT ptCur = {}, ptOut = {-32000,-32000};
	HMONITOR hStartupMonitor = NULL, hMouseMonitor, hPrimaryMonitor;

	GetStartupInfo(&si);
	GetCursorPos(&ptCur);

	// Get primary monitor, it's expected to be started at 0x0, but we can't be sure
	hPrimaryMonitor = MonitorFromPoint(ptOut, MONITOR_DEFAULTTOPRIMARY);

	// Get the monitor where mouse cursor is located
	hMouseMonitor = MonitorFromPoint(ptCur, MONITOR_DEFAULTTONEAREST);

	// si.hStdOutput may have a handle of monitor with shortcut or used taskbar
	if (si.hStdOutput && GetMonitorInfo((HMONITOR)si.hStdOutput, &mi))
	{
		hStartupMonitor = (HMONITOR)si.hStdOutput;
	}

	// Now, due to MS Windows bugs or just an inconsistence,
	// hStartupMonitor has hPrimaryMonitor, if program was started
	// from shortcut, even if it is located on secondary monitor,
	// if it was started by keyboard.
	// So we can trust hStartupMonitor value only when it contains
	// non-primary monitor value (when user clicks shortcut with mouse)
	if (hStartupMonitor && ((hStartupMonitor != hPrimaryMonitor) || (hStartupMonitor == hMouseMonitor)))
		return hStartupMonitor;

	// Otherwise - return monitor where mouse cursor is located
	return hMouseMonitor ? hMouseMonitor : hPrimaryMonitor;
}
开发者ID:akrisiun,项目名称:ConEmu,代码行数:36,代码来源:Monitors.cpp


示例2: MonitorFromPoint

Monitor DisplayManager::Primary() {
    /* The Primary or 'Main' monitor is at (0, 0). */
    const POINT p = { 0, 0 };
    HMONITOR monitor = MonitorFromPoint(p, MONITOR_DEFAULTTOPRIMARY);
    MONITORINFO mInfo = Info(monitor);
    return Monitor(monitor, L"Primary", mInfo.rcMonitor);
}
开发者ID:malensek,项目名称:3RVX,代码行数:7,代码来源:DisplayManager.cpp


示例3: GetCursorPos

void SliderWnd::PositionWindow() {
    POINT p;
    GetCursorPos(&p);

    HMONITOR monitor = MonitorFromPoint(p, MONITOR_DEFAULTTONEAREST);
    MONITORINFO mInfo = {};
    mInfo.cbSize = sizeof(mInfo);
    GetMonitorInfo(monitor, &mInfo);
    RECT mRect = mInfo.rcWork;

    /* Default location is the bottom of the window centered above cursor. */
    POINT loc;
    loc.x = p.x - _size.cx / 2;
    loc.y = p.y - _size.cy;

    /* Reposition the window if it's falling off the monitor somewhere. */
    if (loc.y < mRect.top) {
        loc.y = mRect.top;
    }

    if (loc.x < mRect.left) {
        loc.x = mRect.left;
    }

    if (p.y > mRect.bottom) {
        loc.y = mRect.bottom - _size.cy;
    }

    if (p.x > mRect.right - _size.cx) {
        loc.x = mRect.right - _size.cx;
    }

    Position(loc.x, loc.y);
}
开发者ID:malensek,项目名称:3RVX,代码行数:34,代码来源:SliderWnd.cpp


示例4: MonitorFromPoint

SwapChain::SwapChain()
{
    refreshRate.Numerator = 60;
    refreshRate.Denominator = 1;

    // Try to figure out if we should default to 1280x720 or 1920x1080
    POINT point;
    point.x = 0;
    point.y = 0;
    HMONITOR monitor = MonitorFromPoint(point, MONITOR_DEFAULTTOPRIMARY);
    if(monitor != 0)
    {
        MONITORINFOEX info;
        ZeroMemory(&info, sizeof(info));
        info.cbSize = sizeof(MONITORINFOEX);
        if(GetMonitorInfo(monitor, &info) != 0)
        {
            int32 monitorWidth = info.rcWork.right - info.rcWork.left;
            int32 monitorHeight = info.rcWork.bottom - info.rcWork.top;
            if(monitorWidth > 1920 && monitorHeight > 1080)
            {
                width = 1920;
                height = 1080;
            }
        }
    }
}
开发者ID:TheRealMJP,项目名称:DeferredTexturing,代码行数:27,代码来源:SwapChain.cpp


示例5: GetMonitorLeftmost

int GetMonitorLeftmost(int PosX, int PosY)
{
	OSVERSIONINFO osvi;

	osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
	GetVersionEx(&osvi);
	if ( (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && osvi.dwMajorVersion == 4) ||
	     (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS && osvi.dwMinorVersion < 10) ) {
		// // NT4.0, 95 はマルチモニタAPIに非対応
		return 0;
	}
	else {
		HMONITOR hm;
		POINT pt;
		MONITORINFO mi;

		pt.x = PosX;
		pt.y = PosY;
		hm = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST);

		mi.cbSize = sizeof(MONITORINFO);
		GetMonitorInfo(hm, &mi);
		return mi.rcWork.left;
	}
}
开发者ID:lifangbo,项目名称:teraterm,代码行数:25,代码来源:ttmlib.c


示例6: SetSplashImage

// Calls UpdateLayeredWindow to set a bitmap (with alpha) as the content of the splash window.
static void SetSplashImage(HWND hwndSplash, HBITMAP hbmpSplash)

{
	// get the size of the bitmap
	BITMAP bm;
	GetObject(hbmpSplash, sizeof(bm), &bm);
	SIZE sizeSplash = { bm.bmWidth, bm.bmHeight };

	// get the primary monitor's info
	POINT ptZero = { 0 };
	HMONITOR hmonPrimary = MonitorFromPoint(ptZero, MONITOR_DEFAULTTOPRIMARY);
	MONITORINFO monitorinfo = { 0 };
	monitorinfo.cbSize = sizeof(monitorinfo);
	GetMonitorInfo(hmonPrimary, &monitorinfo);

	// center the splash screen in the middle of the primary work area
	const RECT & rcWork = monitorinfo.rcWork;
	POINT ptOrigin;
	ptOrigin.x = rcWork.left + (rcWork.right - rcWork.left - sizeSplash.cx) / 2;
	ptOrigin.y = rcWork.top + (rcWork.bottom - rcWork.top - sizeSplash.cy) / 2;

	// create a memory DC holding the splash bitmap
	HDC hdcScreen = GetDC(NULL);
	HDC hdcMem = CreateCompatibleDC(hdcScreen);
	HBITMAP hbmpOld = (HBITMAP) SelectObject(hdcMem, hbmpSplash);

	// paint the window (in the right location) with the alpha-blended bitmap
	UpdateLayeredWindow(hwndSplash, hdcScreen, &ptOrigin, &sizeSplash,
		hdcMem, &ptZero, RGB(0, 0, 0), NULL, ULW_OPAQUE);

	// delete temporary objects
	SelectObject(hdcMem, hbmpOld);
	DeleteDC(hdcMem);
	ReleaseDC(NULL, hdcScreen);
}
开发者ID:adhistac,项目名称:ee-client-2-0,代码行数:36,代码来源:win32SplashScreen.cpp


示例7: sizeof

////////////////////////////////////////////////////////////////////////////////////////////////////
// Fills specified SHELLEXECUTEINFO structure with the information read from registry
VOID CConfigReader::PopulateExecuteInformation ( SHELLEXECUTEINFO* pExecInfo )
{
    pExecInfo->cbSize = sizeof ( SHELLEXECUTEINFO ) ;
    pExecInfo->fMask = 
        SEE_MASK_FLAG_DDEWAIT | SEE_MASK_HMONITOR | SEE_MASK_NOASYNC | SEE_MASK_UNICODE ;
    pExecInfo->hwnd = NULL ;
    pExecInfo->lpVerb = g_szShellExecuteVerb ;
    pExecInfo->lpFile = m_lpszPath ;
    pExecInfo->lpParameters = m_lpszParams ;
    pExecInfo->lpDirectory = NULL ;
    pExecInfo->nShow = m_dwWindowState ;

    // Set monitor handle. 0 means primary monitor, if index is greater then zero we will enumerate
    // through all monitors and find the required one using index. 
    if ( 0 < m_dwMonitorIndex )
    {
        FINDMONITOR FindMonitor ;
        FindMonitor.dwCurrentIndex = 0 ;
        FindMonitor.dwRequiredIndex = m_dwMonitorIndex ;
        FindMonitor.hMonitor = NULL ;
        EnumDisplayMonitors ( NULL , NULL , EnumMonitorsCallBack , ( LPARAM ) &FindMonitor ) ;
        if ( NULL != FindMonitor.hMonitor )
        {
            pExecInfo->hMonitor = FindMonitor.hMonitor ;
            return ;
        }
    } // If index is invalid or is 0 we will default to primary monitor
    else
    {
        POINT ptZero = { 0 } ;
        pExecInfo->hMonitor = MonitorFromPoint ( ptZero , MONITOR_DEFAULTTOPRIMARY ) ;
    }
}
开发者ID:sergey-rybalkin,项目名称:QLaunch,代码行数:35,代码来源:ConfigReader.cpp


示例8: ValidatePosition

void ValidatePosition(HWND hwndDlg)
{
	RECT r;
	SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0);

	POINT pt = { 0, 0 };
	HMONITOR hMonitor = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST); // always 

	MONITORINFO monitorInfo;
	monitorInfo.cbSize = sizeof(MONITORINFO);
	if (GetMonitorInfo(hMonitor, &monitorInfo))
		memcpy(&r, &monitorInfo.rcMonitor, sizeof(RECT));

	// /window going off right of screen*
	if (Xposition + WindowWidth >= r.right)
		Xposition = r.right - WindowWidth;

	// window going off bottom of screen
	if (Yposition + WindowHeight >= r.bottom)
		Yposition = r.bottom - WindowHeight;

	// window going off left of screen
	if (Xposition >= r.right)
		Xposition = 0;
}
开发者ID:kmdtukl,项目名称:miranda-ng,代码行数:25,代码来源:webview_datawnd.cpp


示例9: Clock_PositionWindow

void Clock_PositionWindow(HWND hwnd, int padding) {
	POINT cursor_pos;
	MONITORINFO moni = {sizeof(moni)};
	int wProp, hProp;
	HWND hwnd_clock;
	
	GetWindowRect(hwnd, &moni.rcWork); // Options dialog dimensions
	wProp = moni.rcWork.right-moni.rcWork.left;  //----------+++--> Width
	hProp = moni.rcWork.bottom-moni.rcWork.top; //----------+++--> Height
	
	GetCursorPos(&cursor_pos);
	GetMonitorInfo(MonitorFromPoint(cursor_pos,MONITOR_DEFAULTTONEAREST),&moni);
	
	if(moni.rcWork.top!=moni.rcMonitor.top || moni.rcWork.bottom!=moni.rcMonitor.bottom) { // taskbar is horizontal
		moni.rcMonitor.left=moni.rcWork.right-wProp-padding;
		if(moni.rcWork.top!=moni.rcMonitor.top) // top
			moni.rcMonitor.top=moni.rcWork.top+padding;
		else // bottom
			moni.rcMonitor.top=moni.rcWork.bottom-hProp-padding;
		// center small windows within clock dimension when possible
		hwnd_clock = gs_hwndClock;
		if(!hwnd_clock)
			hwnd_clock = FindClock();
		if(hwnd_clock) {
			GetClientRect(hwnd_clock, &moni.rcWork);
			if(wProp < moni.rcWork.right)
				moni.rcMonitor.left -= ((moni.rcWork.right - wProp)>>1) + api.desktop_button_size;
		}
	}else if(moni.rcWork.left!=moni.rcMonitor.left || moni.rcWork.right!=moni.rcMonitor.right){ // vertical
开发者ID:heicks,项目名称:T-Clock,代码行数:29,代码来源:clock_utils.c


示例10: _tmain

int _tmain(int argc, _TCHAR* argv[])
{
    const POINT ptZero = { 0, 0 };
    HMONITOR hMon = MonitorFromPoint(ptZero, MONITOR_DEFAULTTOPRIMARY);

    MONITORINFO monInfo;
    monInfo.cbSize = sizeof monInfo;

    if (GetMonitorInfo(hMon, &monInfo) == TRUE)
    {
        LONG width = monInfo.rcMonitor.right - monInfo.rcMonitor.left;
        LONG height = monInfo.rcMonitor.bottom - monInfo.rcMonitor.top;

        if (SetCursorPos(width / 2, height / 2) != TRUE)
        {
            std::cout << "SetCursorPos() failed, error : " << GetLastError() << "\n";
            return 1;
        }
    }
    else
    {
        std::cout << "GetMonitorInfo() failed, error : " << GetLastError() << "\n";
        return 2;
    }

	return 0;
}
开发者ID:jossgray,项目名称:center_cursor,代码行数:27,代码来源:center_cursor.cpp


示例11: MonitorFromPoint

 // FIXME: There is no guarantee that descMap contains the info required
 // Because of threading issue. Must implement mutex
 DisplayDeviceDescriptor winDisplayDeviceManager::uriFromPoint(int x, int y)
 {
   POINT p;
   p.x = x;
   p.y = y;
   HMONITOR hMon = MonitorFromPoint(p, MONITOR_DEFAULTTOPRIMARY);
   return descMap[hMon];
 }
开发者ID:Rylith,项目名称:TouchpadTestV2,代码行数:10,代码来源:winDisplayDeviceManager.cpp


示例12: CSize

CSize CBCGPPopupDlg::GetOptimalTextSize (CString str)
{
	if (str.IsEmpty ())
	{
		return CSize (0, 0);
	}

	CRect rectScreen;

	CRect rectDlg;
	GetWindowRect (rectDlg);

	MONITORINFO mi;
	mi.cbSize = sizeof (MONITORINFO);
	if (GetMonitorInfo (MonitorFromPoint (rectDlg.TopLeft (), MONITOR_DEFAULTTONEAREST), &mi))
	{
		rectScreen = mi.rcWork;
	}
	else
	{
		::SystemParametersInfo (SPI_GETWORKAREA, 0, &rectScreen, 0);
	}

	CClientDC dc (this);

	CFont* pOldFont = dc.SelectObject (&globalData.fontRegular);
	ASSERT_VALID (pOldFont);

	int nStepY = globalData.GetTextHeight ();
	int nStepX = nStepY * 3;

	CRect rectText (0, 0, nStepX, nStepY);

	for (;;)
	{
		CRect rectTextSaved = rectText;

		int nHeight = dc.DrawText (str, rectText, DT_CALCRECT | DT_WORDBREAK | DT_NOPREFIX);
		int nWidth = rectText.Width ();

		rectText = rectTextSaved;

		if (nHeight <= rectText.Height () ||
			rectText.Width () > rectScreen.Width () ||
			rectText.Height () > rectScreen.Height ())
		{
			rectText.bottom = rectText.top + nHeight + 5;
			rectText.right = rectText.left + nWidth + 5;
			break;
		}

		rectText.right += nStepX;
		rectText.bottom += nStepY;
	}

	dc.SelectObject (pOldFont);
	return rectText.Size ();
}
开发者ID:cugxiangzhenwei,项目名称:WorkPlatForm,代码行数:58,代码来源:BCGPPopupDlg.cpp


示例13: CreateWnd

// CreateWnd: creates a full screen window to span the projectors
void CreateWnd(HINSTANCE &hinst, int width, int height, int depth)
{
	// Find the middle projector
	POINT pt;
	pt.x = -SCRWIDTH;
	pt.y = 100;

	HMONITOR hmon; // monitor handles
	hmon = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST);

	MONITORINFO mi;
	mi.cbSize = sizeof(MONITORINFO);
	GetMonitorInfo(hmon, &mi);

	// Set the window position based on the projector locations
	int posx1 = mi.rcMonitor.left;
	int posy1 = mi.rcMonitor.top;

	// Constants for fullscreen mode
	long wndStyle = WS_POPUP | WS_VISIBLE;

	// create the window
	hwnd1 = CreateWindowEx(NULL,
		WNDCLASSNAME,
		WNDNAME,
		wndStyle | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
		posx1, posy1,
		width, height,
		NULL,
		NULL,
		hinst,
		NULL);

	hdc1 = GetDC(hwnd1);

	PIXELFORMATDESCRIPTOR pfd =
	{
		sizeof(PIXELFORMATDESCRIPTOR),
		1,
		PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
		PFD_TYPE_RGBA,
		SCRDEPTH,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		32,
		0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0
	};
	indexPixelFormat = ChoosePixelFormat(hdc1, &pfd);
	SetPixelFormat(hdc1, indexPixelFormat, &pfd);

	// Setup OpenGL
	hglrc = wglCreateContext(hdc1);
	wglMakeCurrent(hdc1, hglrc);
	glewExperimental = GL_TRUE;
	glewInit();
	InitOpenGL();
	ShowWindow(hwnd1, SW_SHOW);		// everything went OK, show the window
	UpdateWindow(hwnd1);
}
开发者ID:dteinferno,项目名称:OpenGL,代码行数:59,代码来源:winmain.cpp


示例14: PhpUpdateTooltip

static VOID PhpUpdateTooltip(
    __in PPHP_GRAPH_CONTEXT Context
    )
{
    POINT point;
    RECT windowRect;
    HWND hwnd;
    TOOLINFO toolInfo = { sizeof(toolInfo) };
    HMONITOR monitor;

    GetCursorPos(&point);
    GetWindowRect(Context->Handle, &windowRect);

    if (
        point.x < windowRect.left || point.x >= windowRect.right ||
        point.y < windowRect.top || point.y >= windowRect.bottom
        )
        return;

    hwnd = WindowFromPoint(point);

    if (hwnd != Context->Handle)
        return;

    toolInfo.hwnd = Context->Handle;
    toolInfo.uId = 1;

    if (!Context->TooltipVisible)
    {
        TRACKMOUSEEVENT trackMouseEvent = { sizeof(trackMouseEvent) };

        SendMessage(Context->TooltipHandle, TTM_TRACKACTIVATE, TRUE, (LPARAM)&toolInfo);

        trackMouseEvent.dwFlags = TME_LEAVE;
        trackMouseEvent.hwndTrack = Context->Handle;
        TrackMouseEvent(&trackMouseEvent);

        Context->ValidMonitor = NULL; // force a refresh of monitor info
    }

    // Update monitor information only if the tooltip has moved onto another monitor.

    monitor = MonitorFromPoint(point, MONITOR_DEFAULTTONEAREST);

    if (Context->ValidMonitor != monitor)
    {
        GetMonitorInfo(monitor, &Context->MonitorInfo);
        Context->ValidMonitor = monitor;
    }

    // Add an offset to fix the case where the user moves the mouse to the bottom-right.
    point.x += 12;
    point.y += 12;

    SendMessage(Context->TooltipHandle, TTM_TRACKPOSITION, 0, MAKELONG(point.x, point.y));
}
开发者ID:john-peterson,项目名称:processhacker,代码行数:56,代码来源:graph.c


示例15: n2e_ScintillaDPIInit

void n2e_ScintillaDPIInit(const HWND hwnd)
{
  if (!IsWindowsVistaOrGreater())
  {
    return;
  }
  RECT rc = { 0 };
  GetWindowRect(hwnd, &rc);
  const POINT pt = { rc.left, rc.top };
  SciCall_SetDPI(GetDPIFromMonitor(MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY), hwnd));
}
开发者ID:ProgerXP,项目名称:Notepad2e,代码行数:11,代码来源:DPIHelperScintilla.c


示例16: sizeof

//------------------------------------------------------------------------//
void CBCGPGlobalUtils::AdjustRectToWorkArea (CRect& rect, CRect* pRectDelta)
{
	CPoint ptStart;

	if (m_bIsDragging)
	{
		::GetCursorPos (&ptStart);
	}
	else
	{
		ptStart = rect.TopLeft ();
	}

	CRect rectScreen;
	MONITORINFO mi;
	mi.cbSize = sizeof (MONITORINFO);
	if (GetMonitorInfo (
		MonitorFromPoint (ptStart, MONITOR_DEFAULTTONEAREST),
		&mi))
	{
		rectScreen = mi.rcWork;
	}
	else
	{
		::SystemParametersInfo (SPI_GETWORKAREA, 0, &rectScreen, 0);
	}

	int nDelta = pRectDelta != NULL ? pRectDelta->left : 0;

	if (rect.right <= rectScreen.left + nDelta)
	{
		rect.OffsetRect (rectScreen.left - rect.right + nDelta, 0);
	}

	nDelta = pRectDelta != NULL ? pRectDelta->right : 0;
	if (rect.left >= rectScreen.right - nDelta)
	{
		rect.OffsetRect (rectScreen.right - rect.left - nDelta, 0);
	}

	nDelta = pRectDelta != NULL ? pRectDelta->bottom : 0;
	if (rect.top >= rectScreen.bottom - nDelta)
	{
		rect.OffsetRect (0, rectScreen.bottom - rect.top - nDelta);
	}

	nDelta = pRectDelta != NULL ? pRectDelta->top : 0;
	if (rect.bottom < rectScreen.top + nDelta)
	{
		rect.OffsetRect (0, rectScreen.top - rect.bottom + nDelta);
	}
}
开发者ID:iclosure,项目名称:jframework,代码行数:53,代码来源:BCGPGlobalUtils.cpp


示例17: IsRectOnSingleMonitor

static BOOL IsRectOnSingleMonitor(const CRect& rect)
{
	const HMONITOR monitor = MonitorFromPoint(rect.TopLeft(), MONITOR_DEFAULTTONULL);	// Find monitor from top left of rect
	MONITORINFO info;
	info.cbSize = sizeof(info);

	if (!monitor || !GetMonitorInfo(monitor, &info))		// Get monitor's info
		return false;										// fail if not on monitor or no info

	CRect intersection;
	intersection.IntersectRect(&info.rcMonitor, &rect);		// Calculate intersection between rect and monitor
	return intersection == rect;							// rect is fully on monitor iff intersection of rect and monitor is rect
}
开发者ID:EnigmaIndustries,项目名称:graph-studio-next,代码行数:13,代码来源:GraphStudioModelessDialog.cpp


示例18: AmbireCaptureGetScreenSize

FREObject __cdecl AmbireCaptureGetScreenSize(FREContext ctx, void * functionData, uint32_t argc, FREObject argv[]) {
	POINT pt = { 0 };
	HMONITOR hMonitor = MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY);
	MONITORINFO mi = { 0 };
	mi.cbSize = sizeof(mi);
	GetMonitorInfo(hMonitor, &mi);
	int W = mi.rcMonitor.right - mi.rcMonitor.left;
	int H = mi.rcMonitor.bottom - mi.rcMonitor.top;
	int N = W | (H << 16);
	FREObject rv = 0;
	FRENewObjectFromInt32(N, &rv);
	return rv;
}
开发者ID:michaelboyle-smarttech,项目名称:itec-ambire,代码行数:13,代码来源:AmbireCapture-Windows-x86.cpp


示例19: GetObject

// Calls UpdateLayeredWindow to set a bitmap (with alpha) as the content of the splash window.
void CSplashScreen::SetSplashImage(HWND hwndSplash, HBITMAP hbmpSplash)
{
	// get the size of the bitmap
	BITMAP bm;
	POINT ptZero = { 0 };

	GetObject(hbmpSplash, sizeof(bm), &bm);

	SIZE sizeSplash = { bm.bmWidth, bm.bmHeight };

	// get the primary monitor's info
	HMONITOR hmonPrimary = MonitorFromPoint(ptZero, MONITOR_DEFAULTTOPRIMARY);
	MONITORINFO monitorinfo = { 0 };
	monitorinfo.cbSize = sizeof(monitorinfo);
	GetMonitorInfo(hmonPrimary, &monitorinfo);

	// center the splash screen in the middle of the primary work area
	const RECT & rcWork = monitorinfo.rcWork;
	POINT ptOrigin;

	ptOrigin.x = rcWork.left + (rcWork.right - rcWork.left - sizeSplash.cx) / 2;
	ptOrigin.y = rcWork.top + (rcWork.bottom - rcWork.top - sizeSplash.cy) / 2;

	// create a memory DC holding the splash bitmap
	HDC hdcScreen = GetDC(NULL);
	HDC hdcMem = CreateCompatibleDC(hdcScreen);
	HBITMAP hbmpOld = (HBITMAP) SelectObject(hdcMem, hbmpSplash);

	// use the source image's alpha channel for blending
	m_blend.BlendOp = AC_SRC_OVER;
	m_blend.SourceConstantAlpha = 0xff;
	m_blend.AlphaFormat = AC_SRC_ALPHA;

	// paint the window (in the right location) with the alpha-blended bitmap
	UpdateLayeredWindow(hwndSplash, hdcScreen, &ptOrigin, &sizeSplash,hdcMem, &ptZero, RGB(0, 0, 0), &m_blend, ULW_ALPHA);

	// delete temporary objects
	SelectObject(hdcMem, hbmpOld);
	DeleteDC(hdcMem);
	ReleaseDC(NULL, hdcScreen);

	::SetWindowPos(hwndSplash ,       // handle to window
				HWND_TOPMOST,  // placement-order handle
				ptOrigin.x,     // horizontal position
				ptOrigin.y,      // vertical position
				sizeSplash.cx,  // width
				sizeSplash.cy, // height
				SWP_SHOWWINDOW); // window-positioning options);
}
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:50,代码来源:SplashScreen.cpp


示例20: SetupDPI

UINT SetupDPI()
{
    // Just do system DPI awareness for now for simplicity... scale the 3D content
    SetProcessDpiAwareness(PROCESS_SYSTEM_DPI_AWARE);

    UINT dpiX = 0, dpiY;
    POINT pt = { 1, 1 };
    auto hMonitor = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST);
    if (SUCCEEDED(GetDpiForMonitor(hMonitor, MDT_EFFECTIVE_DPI, &dpiX, &dpiY))) {
        return dpiX;
    }
    else {
        return 96; // default
    }
}
开发者ID:nlguillemot,项目名称:spooky,代码行数:15,代码来源:main.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ MonitorFromRect函数代码示例发布时间:2022-05-30
下一篇:
C++ MojTestErrCheck函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap