Exemple #1
0
//创建区域
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,32);
		ImageHandle->BitBlt(BufferImage.GetDC(),0,0,nButtonWidth,nButtomHeight,0,0);
		BufferImage.ReleaseDC();

		//创建区域
		HRGN hRgn=BufferImage.CreateImageRegion(crTrans);
		if (hRgn!=NULL)
		{
			m_crTrans=crTrans;
			SetWindowPos(NULL,0,0,nButtonWidth,nButtomHeight,SWP_NOMOVE);
			SetWindowRgn(hRgn,TRUE);
			m_ButtonRgn.DeleteObject();
			m_ButtonRgn.Attach(hRgn);
			return true;
		}
	}

	return false;
}
Exemple #2
0
//初始化函数
BOOL CScoreView::OnInitDialog()
{
	__super::OnInitDialog();

	//设置数据
	m_lBaseScore=0L;
	m_lGameTax=0L;
	memset(m_lGameScore,0,sizeof(m_lGameScore));
	memset(m_szUserName,0,sizeof(m_szUserName));

	//设置界面
	SetClassLong(m_hWnd,GCL_HBRBACKGROUND,NULL);

	//居中窗口
	CenterWindow(GetParent());

	CImageHandle ImageHandle(&m_ImageBack);
	if (ImageHandle.IsResourceValid())
	{
		//创建临时图
		CSkinImage BufferImage;
		int nImageWidth=m_ImageBack.GetWidth();
		int nImageHeight=m_ImageBack.GetHeight();
		BufferImage.Create(nImageWidth,nImageHeight,32);
		ImageHandle->BitBlt(BufferImage.GetDC(),0,0,nImageWidth,nImageHeight,0,0);
		BufferImage.ReleaseDC();

		//创建区域
		CRgn ImageRgn;
		BufferImage.CreateImageRegion( ImageRgn, RGB( 255, 0, 255 ) );
		if ( (( HRGN )ImageRgn) !=NULL)
		{
			SetWindowPos(NULL,0,0,nImageWidth,nImageHeight,SWP_NOMOVE);
			SetWindowRgn(( HRGN )ImageRgn,TRUE);

			ImageRgn.DeleteObject();

			return true;
		}
	}


	return TRUE;
}
Exemple #3
0
//创建区域
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;
}
//绘画界面
void CSkinWndObject::DrawSkinView(CDC * pDC)
{
	//获取参数
	CRect ClientRect;
	m_pWndHook->GetClientRect(&ClientRect);

	//建立缓冲图
	CSkinImage CaptionImage;
	CaptionImage.Create(ClientRect.Width()-2*m_nXExcursionPos,m_SkinAttribute.m_nCaptionHeigth,16);
	if (CaptionImage.IsNull()) return;

	//绘画背景
	CDC BufferDC;
	BufferDC.CreateCompatibleDC(NULL);
	BufferDC.SelectObject(CaptionImage);
	DrawCaption(&BufferDC,CaptionImage.GetWidth(),CaptionImage.GetHeight());

	//建立 DC
	if (pDC==NULL)
	{
		CClientDC ClientDC(m_pWndHook);
		ClientDC.BitBlt(m_nXExcursionPos,1,CaptionImage.GetWidth(),CaptionImage.GetHeight(),&BufferDC,0,0,SRCCOPY);
		ClientDC.Draw3dRect(&ClientRect,RGB(0,0,0),RGB(0,0,0));
		BufferDC.DeleteDC();
	}
	else
	{
		pDC->BitBlt(m_nXExcursionPos,1,CaptionImage.GetWidth(),CaptionImage.GetHeight(),&BufferDC,0,0,SRCCOPY);
		pDC->Draw3dRect(&ClientRect,RGB(0,0,0),RGB(0,0,0));
	}

	//获取标题
	TCHAR strTitle[128];
	GetWindowText(*m_pWndHook,strTitle,CountArray(strTitle));

	//计算位置
	INT nYPos=(m_SkinAttribute.m_nCaptionHeigth-12)/2+2;
	INT nXPos=46;

	//建立缓冲图
	CClientDC ClientDC(m_pWndHook);
	ClientDC.SetBkMode(TRANSPARENT);
	ClientDC.SelectObject(m_SkinAttribute.m_DefaultFont);
	ClientDC.SetTextAlign(TA_LEFT);

	//变量定义
	int nStringLength=lstrlen(strTitle);
	int nXExcursion[8]={1,1,1,0,-1,-1,-1,0};
	int nYExcursion[8]={-1,0,1,1,1,0,-1,-1};

	//绘画边框
	ClientDC.SetTextColor(RGB(0,112,192));
	for (int i=0;i<CountArray(nXExcursion);i++)
	{
		ClientDC.TextOut(nXPos+nXExcursion[i],nYPos+nYExcursion[i],strTitle,nStringLength);
	}

	//绘画标题m_SkinAttribute.m_crCaptionTXColor
	ClientDC.SetTextColor(RGB(255,255,255));
	ClientDC.TextOut(nXPos,nYPos,strTitle);

	BufferDC.DeleteDC();

	return;
}
Exemple #5
0
//绘画界面
void CSkinWndObject::DrawSkinView(CDC * pDC)
{
	//获取参数
	CRect ClientRect;
	m_pWndHook->GetClientRect(&ClientRect);
    
	//建立缓冲图
	CSkinImage CaptionImage;
	CaptionImage.Create(ClientRect.Width(),m_SkinAttribute.m_nCaptionHeigth,24);
	if (CaptionImage.IsNull()) return;

	//绘画背景
	CDC BufferDC;
	BufferDC.CreateCompatibleDC(NULL);
	BufferDC.SelectObject(CaptionImage);
	DrawCaption(&BufferDC,CaptionImage.GetWidth(),CaptionImage.GetHeight());
    
	//建立 DC
	if (pDC==NULL)
	{
		CClientDC ClientDC(m_pWndHook);
		ClientDC.BitBlt(m_nXExcursionPos,0,CaptionImage.GetWidth(),CaptionImage.GetHeight(),&BufferDC,0,0,SRCCOPY);
		//ClientDC.Draw3dRect(&ClientRect,RGB(0,0,0),RGB(0,0,0));
		BufferDC.DeleteDC();
	}
	else
	{
		pDC->BitBlt(m_nXExcursionPos,0,CaptionImage.GetWidth(),CaptionImage.GetHeight(),&BufferDC,0,0,SRCCOPY);
		//pDC->Draw3dRect(&ClientRect,RGB(0,0,0),RGB(0,0,0));
	}

	//获取标题
	TCHAR strTitle[128];
	GetWindowText(*m_pWndHook,strTitle,CountArray(strTitle));

	//计算位置
	INT nYPos=(m_SkinAttribute.m_nCaptionHeigth-12)/2+2;
	INT nXPos=35;

	//建立缓冲图
	CClientDC ClientDC(m_pWndHook);
	ClientDC.SetBkMode(TRANSPARENT);
	ClientDC.SelectObject(m_SkinAttribute.m_DefaultFont);
	ClientDC.SetTextAlign(TA_LEFT);	

	//变量定义
	int nStringLength=lstrlen(strTitle);
	int nXExcursion[8]={1,1,1,0,-1,-1,-1,0};
	int nYExcursion[8]={-1,0,1,1,1,0,-1,-1};

	int nXExcursion1=GetXExcursionPos();
	int nYExcursion1=GetYExcursionPos();

	CImageHandle m_FramLeft(&m_SkinAttribute.m_FramLeft);
	if (m_SkinAttribute.m_FramLeft.IsNull()) return ;
	CImageHandle m_BottomM(&m_SkinAttribute.m_BottomM);
	if (m_SkinAttribute.m_BottomM.IsNull()) return ;
	CImageHandle m_FramRight(&m_SkinAttribute.m_FramRight);
	if (m_SkinAttribute.m_FramRight.IsNull()) return ;

	CImageHandle BottomL(&m_SkinAttribute.m_BottomL);
	if (m_SkinAttribute.m_BottomL.IsNull()) return ;

	CImageHandle BottomR(&m_SkinAttribute.m_BottomR);
	if (m_SkinAttribute.m_BottomR.IsNull()) return ;


	int nLeftWidth=m_FramLeft->GetHeight();
	int nMidWidth=m_BottomM->GetWidth();
	int nRightWidth=m_FramRight->GetHeight();
    
	for (int i=ClientRect.top+CaptionImage.GetHeight();i<ClientRect.bottom-BottomL->GetHeight();i+=nLeftWidth)
		m_SkinAttribute.m_FramLeft.BitBlt(ClientDC,nXExcursion1,i);

	for (int i=ClientRect.top+CaptionImage.GetHeight();i<ClientRect.bottom-BottomR->GetHeight();i+=nRightWidth)
		m_SkinAttribute.m_FramRight.BitBlt(ClientDC,ClientRect.Width()-nXExcursion1-m_FramRight->GetWidth(),i);
    
	for (int i=nXExcursion1+BottomL->GetWidth();i<ClientRect.Width()-m_FramRight->GetWidth();i+=nMidWidth)
		m_SkinAttribute.m_BottomM.BitBlt(ClientDC,i,ClientRect.Height()-m_BottomM->GetHeight());
    
    m_SkinAttribute.m_BottomL.BitBlt(ClientDC,0,ClientRect.Height()-BottomL->GetHeight());
   
	m_SkinAttribute.m_BottomR.BitBlt(ClientDC,ClientRect.Width()-BottomR->GetWidth()-nXExcursion1,ClientRect.Height()-BottomR->GetHeight());
    
	//绘画边框
// 	ClientDC.SetTextColor(RGB(231,192,137));
// 	for (int i=0;i<CountArray(nXExcursion);i++)
// 	{
// 		ClientDC.TextOut(nXPos,nYPos,strTitle,nStringLength);
// 	}

	//CImageHandle TitleLeft1(&m_SkinAttribute.m_TitleLeft);
	//if (m_SkinAttribute.m_TitleLeft1.IsNull()) return ;
	//CImageHandle TitleMid1(&m_SkinAttribute.m_TitleMid);
	//if (m_SkinAttribute.m_TitleMid1.IsNull()) return ;
	//CImageHandle TitleRight1(&m_SkinAttribute.m_TitleRight);
	//if (m_SkinAttribute.m_TitleRight1.IsNull()) return ;

	//int nLeftWidth=TitleLeft1->GetHeight();
	//int nMidWidth=TitleMid1->GetWidth();
	//int nRightWidth=TitleRight1->GetWidth();
	/*for (int i=ClientRect.top;i<ClientRect.bottom;i+=nLeftWidth)
		TitleLeft1->BitBlt(BufferDC.m_hDC,ClientRect.left,i);*/
	/*for (int i=nLeftWidth;i<nXMinDrawPause;i+=nMidWidth) TitleMid1->BitBlt(pDC->m_hDC,i,0);
	TitleRight1->BitBlt(pDC->m_hDC,nXMinDrawPause,0);*/

	//绘画标题m_SkinAttribute.m_crCaptionTXColor
	//ClientDC.SetTextColor(m_SkinAttribute.m_crCaptionTXColor);
	//ClientDC.TextOut(nXPos,nYPos,strTitle);

	/*for (int i=ClientRect.top;i<ClientRect.bottom;i+=nLeftWidth)
		TitleLeft1->BitBlt(BufferDC.m_hDC,ClientRect.left,i);*/
	BufferDC.DeleteDC();

	return;
}