コード例 #1
0
ファイル: SkinDialog.cpp プロジェクト: Michael-Z/qipai-game
//创建区域
bool CRgnDialog::CreateControlRgn(COLORREF crTrans)
{
	//加载资源
	CImageHandle ImageHandle(&m_ImageBack);

	//创建区域
	CRgn RgnControl;
	m_ImageBack.CreateImageRegion(RgnControl,crTrans);

	//设置窗口
	if (RgnControl.GetSafeHandle()!=NULL)
	{
		//移动窗口
		SetWindowRgn(RgnControl,TRUE);
		SetWindowPos(NULL,0,0,m_ImageBack.GetWidth(),m_ImageBack.GetHeight(),SWP_NOMOVE);

		//删除区域
		m_DialogRgn.DeleteObject();
		m_DialogRgn.Attach(RgnControl.Detach());

		return true;
	}

	return false;
}
コード例 #2
0
// @pymethod int|PyCRgn|GetSafeHandle|A HANDLE to the attached Windows GDI object; otherwise NULL if no object is attached
// Return Values: the handle of the CRgn object
PyObject *
PyCRgn::get_safe_handle(PyObject *self, PyObject *args)
	{
	CRgn *pRgn = PyCRgn::GetRgn(self);
	if (!pRgn) return NULL;
	CHECK_NO_ARGS2(args,GetSafeHandle);
	HGDIOBJ hgdiobj=pRgn->GetSafeHandle();
	return Py_BuildValue("l",hgdiobj);
	}
コード例 #3
0
// @pymethod int|PyCRgn|DeleteObject|Deletes the attached Windows GDI Rgn object from memory by freeing all system storage associated with the Windows GDI object
// Return Values: None
PyObject *
PyCRgn::delete_object(PyObject *self, PyObject *args)
	{
	CRgn *pRgn = PyCRgn::GetRgn(self);
	if (!pRgn) return NULL;

	CHECK_NO_ARGS2(args,DeleteObject);
	
	BOOL ok=TRUE;
	if(pRgn->GetSafeHandle())
		ok=pRgn->DeleteObject();
	if(!ok)
		RETURN_ERR("DeleteObject failed");
	pRgn->m_hObject=0; // assert 

	RETURN_NONE;
	}
コード例 #4
0
ファイル: SkinButton.cpp プロジェクト: anyboo/project
//创建区域
bool CRgnButton::CreateControlRgn(COLORREF crTrans)
{
	CImageHandle ImageHandle(&m_ImageBack);
	if (ImageHandle.IsResourceValid())
	{
		//创建临时图
		CSkinImage BufferImage;
		int nButtonWidth=m_ImageBack.GetWidth()/5;
		int nButtomHeight=m_ImageBack.GetHeight();
		BufferImage.Create(nButtonWidth,nButtomHeight,24);
		ImageHandle->BitBlt(BufferImage.GetDC(),0,0,nButtonWidth,nButtomHeight,0,0);
		BufferImage.ReleaseDC();

		//创建区域
		CRgn RgnControl;
		BufferImage.CreateImageRegion(RgnControl,crTrans);

		//创建区域
		if (RgnControl.GetSafeHandle()!=NULL)
		{
			//设置变量
			m_crTrans=crTrans;

			//设置按钮
			SetWindowRgn(RgnControl,TRUE);
			SetWindowPos(NULL,0,0,nButtonWidth,nButtomHeight,SWP_NOMOVE|SWP_NOACTIVATE);

			//设置区域
			m_ButtonRgn.DeleteObject();
			m_ButtonRgn.Attach(RgnControl.Detach());

			return true;
		}
	}

	return false;
}
コード例 #5
0
ファイル: ExtLabel.cpp プロジェクト: OmerMor/SCICompanion-1
void CExtAviLabel::DoPaint( CDC * pDC, CRect & rcClient )
{
	ASSERT_VALID( this );
CSize sizeClient = rcClient.Size();
	if( sizeClient.cx <= 0 || sizeClient.cy <= 0 )
		return;
	if( ! ::RectVisible( pDC->GetSafeHdc(), &rcClient ) )
		return;
CExtMemoryDC dc( pDC, &rcClient );
CRgn rgnClient;
	if( rgnClient.CreateRectRgnIndirect( &rcClient ) )
		dc.SelectClipRgn( &rgnClient );
	OnEraseBackground( dc, rcClient );
	if( ( ! AviIsEmpty() ) && ( m_bSeek || m_bPlaying || ( ( ! m_bPlaying ) && ( ( AviStyleGet() & __EXT_AVI_EMPTY_BACKGROUND_ON_STOP ) == 0 ) ) ) )
	{
//		OnAviPaintCurrentFrame( dc, rcClient, m_sizeAvi );
		DWORD dwWndStyle = GetStyle();
		DWORD dwWndType = (dwWndStyle&SS_TYPEMASK);
		bool bCenterImage = ( (dwWndStyle&SS_CENTERIMAGE) != 0 );
		e_ImageMode_t eImageMode = GetImageMode();
		if( eImageMode == eStretch )
		{
			CSize sizeAvi = rcClient.Size();
			OnAviPaintCurrentFrame( dc, rcClient, sizeAvi );
		}
		else if( eImageMode == eTouchInside || eImageMode == eTouchOutside )
		{
			CRect rcTouchSurface = rcClient;
			CExtMemoryDC dcTouch( &dc, rcTouchSurface, CExtMemoryDC::MDCOPT_TO_MEMORY|CExtMemoryDC::MDCOPT_FILL_BITS|CExtMemoryDC::MDCOPT_RTL_COMPATIBILITY );
			if( dcTouch.GetSafeHdc() )
			{
				CSize sizeTouchSrc = rcTouchSurface.Size();
				CSize sizeBmp = m_sizeAvi;
				double lfAspectX = double(rcTouchSurface.Width())  / double(sizeBmp.cx);
				double lfAspectY = double(rcTouchSurface.Height()) / double(sizeBmp.cy);
				double lfAspect = ( eImageMode == eTouchInside ) ? ( min( lfAspectX, lfAspectY ) ) : ( max( lfAspectX, lfAspectY ) );
				CSize sizeNew( LONG(double(sizeBmp.cx)*lfAspect), LONG(double(sizeBmp.cy)*lfAspect) );
				CRect rcTouchDst( rcTouchSurface.left, rcTouchSurface.top, rcTouchSurface.left + sizeNew.cx, rcTouchSurface.top + sizeNew.cy );
				if( eImageMode == eTouchInside )
				{
					if( sizeNew.cx > sizeTouchSrc.cx )
						rcTouchDst.OffsetRect( ( sizeNew.cx - sizeTouchSrc.cx ) / 2, 0 );
					if( sizeNew.cy > sizeTouchSrc.cy )
						rcTouchDst.OffsetRect( 0, ( sizeNew.cy - sizeTouchSrc.cy ) / 2 );
				}
				else
				{
					rcTouchDst.OffsetRect( - ( sizeNew.cx - sizeTouchSrc.cx ) / 2, 0 );
					rcTouchDst.OffsetRect( 0, - ( sizeNew.cy - sizeTouchSrc.cy ) / 2 );
				}
				CSize sizeAvi = rcTouchDst.Size();
				OnAviPaintCurrentFrame( dcTouch, rcTouchDst, sizeAvi );
			}
		}
		else if( eImageMode == eTile )
		{
			UINT nStepCountH = sizeClient.cx / m_sizeAvi.cx + ( ( sizeClient.cx % m_sizeAvi.cx ) ? 1 : 0 );
			UINT nStepCountV = sizeClient.cy / m_sizeAvi.cy + ( ( sizeClient.cy % m_sizeAvi.cy ) ? 1 : 0 );
			if( nStepCountH > 0 && nStepCountV > 0 )
			{
				UINT nStepIndexH, nStepIndexV;
				for( nStepIndexV = 0; nStepIndexV < nStepCountV; nStepIndexV ++ )
				{
					CRect rcWalk( rcClient.TopLeft(), m_sizeAvi );
					rcWalk.OffsetRect( 0, m_sizeAvi.cy * nStepIndexV );
					for( nStepIndexH = 0; nStepIndexH < nStepCountH; nStepIndexH ++ )
					{
						if( ::RectVisible( dc.GetSafeHdc(), &rcWalk ) )
							OnAviPaintCurrentFrame( dc, rcWalk, m_sizeAvi );
						rcWalk.OffsetRect( m_sizeAvi.cx, 0 );
					}
				}
			}
		}
		else if( eImageMode == eAlign )
		{
			CRect rcDst( rcClient.left, rcClient.top, rcClient.left + m_sizeAvi.cx, rcClient.top + m_sizeAvi.cy );
			bool bCenterHorizontally = false;
			switch( dwWndType )
			{
			case SS_RIGHT:  rcDst.OffsetRect( rcClient.right - rcDst.right, 0 ); break;
			case SS_CENTER: bCenterHorizontally = true;        break;
			default: /* all the other types assumed as left */ break;
			}
			if( bCenterHorizontally )
				rcDst.OffsetRect( ( (rcClient.right - rcClient.left) - (rcDst.right - rcDst.left) ) / 2, 0 );
			if( bCenterImage )
				rcDst.OffsetRect( 0, ( (rcClient.bottom - rcClient.top) - (rcDst.bottom - rcDst.top) ) / 2 );
			OnAviPaintCurrentFrame( dc, rcDst, m_sizeAvi );
		}
	}
	PmBridge_GetPM()->OnPaintSessionComplete( this );
	if( rgnClient.GetSafeHandle() != NULL )
		dc.SelectClipRgn( &rgnClient );	
}
コード例 #6
0
ファイル: ExtLabel.cpp プロジェクト: OmerMor/SCICompanion-1
void CExtLabel::DoPaint( CDC * pDC, CRect & rcClient )
{
	ASSERT_VALID( this );
	ASSERT_VALID( pDC );
CExtMemoryDC dc( pDC, &rcClient );
CRgn rgnClient;
	if( rgnClient.CreateRectRgnIndirect( &rcClient ) )
		dc.SelectClipRgn( &rgnClient );
	OnEraseBackground( dc, rcClient );
DWORD dwWndStyle = GetStyle();
DWORD dwWndType = (dwWndStyle&SS_TYPEMASK);
bool bCenterImage = ( (dwWndStyle&SS_CENTERIMAGE) != 0 );
	if( ! m_bmp.IsEmpty() )
	{
		bool bSmootherAsPossible = true;
		e_ImageMode_t eImageMode = GetImageMode();
		if( eImageMode == eStretch )
			m_bmp.AlphaBlendSkinParts( dc.GetSafeHdc(), rcClient, CRect(0,0,0,0), CExtBitmap::__EDM_STRETCH, true, bSmootherAsPossible );
		else if( eImageMode == eTouchInside || eImageMode == eTouchOutside )
		{
			CRect rcTouchSurface = rcClient;
			CExtMemoryDC dcTouch( &dc, rcTouchSurface, CExtMemoryDC::MDCOPT_TO_MEMORY|CExtMemoryDC::MDCOPT_FILL_BITS|CExtMemoryDC::MDCOPT_RTL_COMPATIBILITY );
			if( dcTouch.GetSafeHdc() )
			{
				CSize sizeTouchSrc = rcTouchSurface.Size();
				CSize sizeBmp = m_bmp.GetSize();
				double lfAspectX = double(rcTouchSurface.Width())  / double(sizeBmp.cx);
				double lfAspectY = double(rcTouchSurface.Height()) / double(sizeBmp.cy);
				double lfAspect = ( eImageMode == eTouchInside ) ? ( min( lfAspectX, lfAspectY ) ) : ( max( lfAspectX, lfAspectY ) );
				CSize sizeNew( LONG(double(sizeBmp.cx)*lfAspect), LONG(double(sizeBmp.cy)*lfAspect) );
				CRect rcTouchDst( rcTouchSurface.left, rcTouchSurface.top, rcTouchSurface.left + sizeNew.cx, rcTouchSurface.top + sizeNew.cy );
				if( eImageMode == eTouchInside )
				{				
					if( sizeNew.cx > sizeTouchSrc.cx )
						rcTouchDst.OffsetRect( ( sizeNew.cx - sizeTouchSrc.cx ) / 2, 0 );
					if( sizeNew.cy > sizeTouchSrc.cy )
						rcTouchDst.OffsetRect( 0, ( sizeNew.cy - sizeTouchSrc.cy ) / 2 );
				}
				else
				{
					rcTouchDst.OffsetRect( - ( sizeNew.cx - sizeTouchSrc.cx ) / 2, 0 );
					rcTouchDst.OffsetRect( 0, - ( sizeNew.cy - sizeTouchSrc.cy ) / 2 );
				}
				INT nOldStretchBltMode = bSmootherAsPossible ? ( ::GetStretchBltMode( dcTouch.m_hDC ) ) : ( COLORONCOLOR ) ;
				if( bSmootherAsPossible )
					::SetStretchBltMode( dcTouch.m_hDC, ( g_PaintManager.m_bIsWinNT ) ? HALFTONE : COLORONCOLOR );
				m_bmp.AlphaBlend( dcTouch.m_hDC, rcTouchDst );
				if( bSmootherAsPossible )
					::SetStretchBltMode( dcTouch.m_hDC, nOldStretchBltMode );
			}
		}
		else if( eImageMode == eTile )
			m_bmp.AlphaBlendSkinParts(  dc.GetSafeHdc(), rcClient, CRect(0,0,0,0), CExtBitmap::__EDM_TILE, true, bSmootherAsPossible );
		else if( eImageMode == eAlign )
		{
			CSize szSize = m_bmp.GetSize();
			CRect rcDst( rcClient.left, rcClient.top, rcClient.left + szSize.cx, rcClient.top + szSize.cy );
			bool bCenterHorizontally = false;
			switch( dwWndType )
			{
			case SS_RIGHT:  rcDst.OffsetRect( rcClient.right - rcDst.right, 0 ); break;
			case SS_CENTER: bCenterHorizontally = true;        break;
			default: /* all the other types assumed as left */ break;
			}
			if( bCenterHorizontally )
				rcDst.OffsetRect( ( (rcClient.right - rcClient.left) - (rcDst.right - rcDst.left) ) / 2, 0 );
			if( bCenterImage )
				rcDst.OffsetRect( 0, ( (rcClient.bottom - rcClient.top) - (rcDst.bottom - rcDst.top) ) / 2 );
			CRect rcSrc( 0, 0, szSize.cx, szSize.cy );
			rcDst.top = max( rcDst.top, rcClient.top );
			rcDst.left = max( rcDst.left, rcClient.left );
			rcDst.bottom = min( rcDst.bottom, rcClient.bottom );
			rcDst.right = min( rcDst.right, rcClient.right );
			if( ::RectVisible( dc.GetSafeHdc(), &rcDst ) )
			{
				INT nOldStretchBltMode = bSmootherAsPossible ? ( ::GetStretchBltMode( dc.m_hDC ) ) : ( COLORONCOLOR );
				if( bSmootherAsPossible )
					::SetStretchBltMode( dc.m_hDC, ( g_PaintManager.m_bIsWinNT ) ? HALFTONE : COLORONCOLOR );
				m_bmp.AlphaBlend( dc.m_hDC, rcDst, rcSrc );
				if( bSmootherAsPossible )
					::SetStretchBltMode( dc.m_hDC, nOldStretchBltMode );
			}
		}
	}
	else if( dwWndType == SS_ICON )
	{
		HICON hIcon = GetIcon();
		if( hIcon != NULL )
		{
			CExtCmdIcon _icon;
			_icon.AssignFromHICON( hIcon, true );
			CSize szIcon = _icon.GetSize();
			int nOffsetX = bCenterImage ? (rcClient.Width() - szIcon.cx) / 2 : 0;
			int nOffsetY = bCenterImage ? (rcClient.Height() - szIcon.cy) / 2 : 0;
			_icon.Paint(
				PmBridge_GetPM(), dc.GetSafeHdc(), rcClient.left + nOffsetX, rcClient.top + nOffsetY, -1, -1,
				IsWindowEnabled() ? CExtCmdIcon::__PAINT_NORMAL : CExtCmdIcon::__PAINT_DISABLED
				);
		}
	}
	else
	{
		CExtSafeString strText;
		int nTextLen = GetWindowTextLength();
		if( nTextLen > 0 )
		{
			GetWindowText( strText.GetBuffer( nTextLen + 2 ), nTextLen + 1 );
			strText.ReleaseBuffer();
		}
		if( strText.GetLength() > 0 )
		{
			DWORD dwDrawTextFlags = 0;
			switch( dwWndType )
			{
			case SS_RIGHT:           dwDrawTextFlags = DT_RIGHT;  break; 
			case SS_CENTER:          dwDrawTextFlags = DT_CENTER; break;
			case SS_LEFTNOWORDWRAP:  dwDrawTextFlags = DT_LEFT;   break;
			default: /* all the other types assumed as left */ dwDrawTextFlags = DT_LEFT; break;
			} // switch( dwWndType )
			if( strText.Find( _T('\t') ) != -1 ) // do tabs expanding
				dwDrawTextFlags |= DT_EXPANDTABS;
			if(		(dwWndType == SS_SIMPLE)
				||	(dwWndStyle&(SS_CENTERIMAGE|SS_ENDELLIPSIS|SS_PATHELLIPSIS)) != 0
				)
			{
				dwDrawTextFlags |= DT_SINGLELINE;
				if( (dwWndStyle&SS_CENTERIMAGE) != 0 )
					dwDrawTextFlags |= DT_VCENTER;
				if( (dwWndStyle&SS_ENDELLIPSIS) != 0 )
					dwDrawTextFlags |= DT_END_ELLIPSIS;
				if( (dwWndStyle&SS_PATHELLIPSIS) != 0 )
					dwDrawTextFlags |= DT_PATH_ELLIPSIS;
			}
			else
				dwDrawTextFlags |= DT_WORDBREAK;
			if( dwWndType == SS_LEFTNOWORDWRAP )
				dwDrawTextFlags &= ~(DT_WORDBREAK|DT_SINGLELINE);
			if( (dwWndStyle&SS_NOPREFIX) != 0 )
				dwDrawTextFlags |= DT_NOPREFIX;
			bool bEnabled = IsWindowEnabled() ? true : false;
			OnDrawLabelText( dc, rcClient, strText, dwDrawTextFlags, bEnabled );
		} // if( strText.GetLength() > 0 )
	}
	PmBridge_GetPM()->OnPaintSessionComplete( this );
	if( rgnClient.GetSafeHandle() != NULL )
		dc.SelectClipRgn( &rgnClient );	
}