コード例 #1
0
//*************************************************************************************
BOOL CBCGPDialog::SetBackgroundImage (UINT uiBmpResId,
									BackgroundLocation location,
									BOOL bRepaint)
{
	HBITMAP hBitmap = NULL;

	if (uiBmpResId != 0)
	{
		//-----------------------------
		// Try to load PNG image first:
		//-----------------------------
		CBCGPPngImage pngImage;
		if (pngImage.Load (MAKEINTRESOURCE (uiBmpResId)))
		{
			hBitmap = (HBITMAP) pngImage.Detach ();
		}
		else
		{
			hBitmap = ::LoadBitmap (AfxGetResourceHandle (), MAKEINTRESOURCE (uiBmpResId));
		}

		if (hBitmap == NULL)
		{
			ASSERT (FALSE);
			return FALSE;
		}
	}

	SetBackgroundImage (hBitmap, location, TRUE /* Autodestroy */, bRepaint);
	return TRUE;
}
コード例 #2
0
//*****************************************************************************
BOOL CBCGPRibbonStatusBarPane::SetAnimationList (UINT uiAnimationListResID, int cxAnimation,
												 COLORREF clrTransp, BOOL bDontScaleInHighDPIMode)
{
	ASSERT_VALID (this);

	if (m_AnimImages.IsValid ())
	{
		m_AnimImages.Clear ();
	}

	if (uiAnimationListResID == 0)
	{
		return TRUE;
	}

	LPCTSTR lpszResourceName = MAKEINTRESOURCE (uiAnimationListResID);
	ASSERT(lpszResourceName != NULL);

	HBITMAP hbmp = NULL;

	//-----------------------------
	// Try to load PNG image first:
	//-----------------------------
	CBCGPPngImage pngImage;
	if (pngImage.Load (lpszResourceName))
	{
		hbmp = (HBITMAP) pngImage.Detach ();
	}
	else
	{
		HINSTANCE hinstRes = AfxFindResourceHandle (lpszResourceName, RT_BITMAP);
		if (hinstRes == NULL)
		{
			return FALSE;
		}

		UINT uiLoadImageFlags = LR_CREATEDIBSECTION | LR_LOADMAP3DCOLORS;

		hbmp = (HBITMAP) ::LoadImage (
			hinstRes,
			lpszResourceName,
			IMAGE_BITMAP,
			0, 0,
			uiLoadImageFlags);
	}

	if (hbmp == NULL)
	{
		return FALSE;
	}

	SetAnimationList (hbmp, cxAnimation, clrTransp, bDontScaleInHighDPIMode);
	return TRUE;
}