Example #1
0
//----默认的窗口非客户区绘制消息处理函数------------------------------------------
//描述: 该函数为内部函数,在DefWindowPorc的MSG_NCPAINT中被调用.
//参数:pMsg: 消息指针.
//返回:无.
//------------------------------------------------------------------------------
static void DefWindowProc_NCPAINT(MSG *pMsg)
{
    HWND hwnd=pMsg->hwnd;
    HDC hdc;
    RECT rc;

    if(HWND_Lock(hwnd))
    {
        hdc =GetWindowDC(hwnd);
        if(NULL!=hdc)
        {
            _GetWindowRect(hwnd,&rc);
            _ScreenToWindow(hwnd,(POINT*)&rc,2);

            if(hwnd->Style&WS_BORDER)
            {
                SetDrawColor(hdc,WINDOW_BORDER_COLOR);
                DrawRect(hdc,&rc);
                InflateRect(&rc,-1,-1);
            }

            if(hwnd->Style&WS_DLGFRAME)
            {
                SetDrawColor(hdc,WINDOW_DLGFRAME_COLOR1);
                DrawRect(hdc,&rc);
                InflateRect(&rc,-1,-1);

                SetDrawColor(hdc,WINDOW_DLGFRAME_COLOR2);
                DrawRect(hdc,&rc);
                InflateRect(&rc,-1,-1);

                SetDrawColor(hdc,WINDOW_DLGFRAME_COLOR3);
                DrawRect(hdc,&rc);
                InflateRect(&rc,-1,-1);

            }

            if(hwnd->Style&WS_CAPTION)
            {
                rc.bottom =rc.top+hwnd->CaptionSize;

                GradientFillRect(hdc,&rc,RGB(180,180,200),RGB(0,0,180),GFILL_U_D);

                SetTextColor(hdc,WINDOW_CAPTION_TEXT_COLOR);
                InflateRect(&rc,-1,-1);
                DrawText(hdc,hwnd->Text,-1,&rc,DT_LEFT|DT_VCENTER);
            }

            ReleaseDC(hwnd,hdc);
        }

        HWND_Unlock(hwnd);
    }


}
Example #2
0
// Draw TreeCtrl Background - 
void VividTree::DrawBackGround( CDC* pDC )
{
	BkMode mode = m_bkgd_mode;

	if ( mode == BK_MODE_BMP )
	{
		if ( !m_bmp_back_ground.GetSafeHandle() )
			mode = BK_MODE_GRADIENT;
	}
	if ( mode == BK_MODE_GRADIENT )
	{
		GradientFillRect( pDC, 
			CRect( m_h_offset, m_v_offset, m_h_size + m_h_offset, m_v_size + m_v_offset ), 
			m_gradient_bkgd_from, m_gradient_bkgd_to, !m_gradient_horz );
	}
	else if ( mode == BK_MODE_FILL )
		pDC->FillSolidRect( m_rect, pDC->GetBkColor() ); 
	else if ( mode == BK_MODE_BMP )
	{
		BITMAP bm;
		CDC dcMem;
	      
		VERIFY(m_bmp_back_ground.GetObject(sizeof(bm), (LPVOID)&bm));
		dcMem.CreateCompatibleDC(NULL);
		CBitmap* bmp_old = (CBitmap*)dcMem.SelectObject( &m_bmp_back_ground ); 
		
		if ( m_bmp_tiled_mode ) 	// BitMap Tile Mode
		{
			for ( int y = 0; y <= (m_v_size / bm.bmHeight); y++ )
			{
				for ( int x = 0; x <= (m_h_size / bm.bmWidth); x++ )
				{
					pDC->BitBlt((x*bm.bmWidth) + m_h_offset, (y*bm.bmHeight) + m_v_offset,
						bm.bmWidth, bm.bmHeight, &dcMem, 0, 0, SRCCOPY);
				}
			}
		}
		else  // BITMAP Stretch Mode
		{
			pDC->StretchBlt( m_h_offset, m_v_offset, m_h_size, m_v_size, 
				&dcMem, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY );
		}
		// CleanUp
		dcMem.SelectObject( bmp_old );
	}
	else
		ASSERT( 0 );  // Unknown BackGround Mode
}
Example #3
0
void GradientFillRectV( HDC hdc,const RECT *rcFill, COLORREF crTop, COLORREF crBottom)
{
	GradientFillRect(hdc, rcFill, crTop,crBottom,TRUE);
}
Example #4
0
void GradientFillRectH(HDC hdc, const RECT *rcFill, COLORREF crLeft, COLORREF crRight)
{
    GradientFillRect(hdc, rcFill, crLeft,crRight,FALSE);
}
Example #5
0
void GradientFillRect(HDC hdc, const CRect &rt,COLORREF crColor1,COLORREF crColor2,int fillType)
{
    COLORREF Color[2]= {crColor1,crColor2};
    GradientFillRect(hdc,rt,Color,fillType);
}
Example #6
0
void CSkinHeaderCtrl::DoPaint(CDC *pDC)
{
	CRect rect, rcItem;
	GetClientRect(&rect);
	
	CDC memDC;
	CBitmap bmp;
	memDC.CreateCompatibleDC(pDC);
	bmp.CreateCompatibleBitmap(pDC,rect.Width(),rect.Height());
	memDC.SelectObject(&bmp);
	memDC.FillSolidRect(rect,RGB(255,255,255));

	memDC.SetBkMode(TRANSPARENT);
	memDC.SetTextColor(RGB(255,255,255));
	
	int nItems = GetItemCount();
	for (int i = 0; i < nItems; ++i)
	{
		TCHAR buf[256];
		HDITEM hditem;

		hditem.mask = HDI_TEXT | HDI_FORMAT | HDI_ORDER;
		hditem.pszText = buf;
		hditem.cchTextMax = 255;
		GetItem(i, &hditem);
		GetItemRect(i, &rcItem);

		if (rcItem.IsRectEmpty())
		{
			continue;
		}

		// 转换
		RectF rcfDestRect;
		rcfDestRect.X = rcItem.left;
		rcfDestRect.Y = rcItem.top;
		rcfDestRect.Width = rcItem.Width();
		rcfDestRect.Height = rcItem.Height();

		//渐变填充
		GradientFillRect(memDC.GetSafeHdc(),rcItem,RGB(100,100,122),RGB(255,0,0),1);
	//	memDC.FillSolidRect(rcItem,m_BkColor);

		CRect LineRect= rcItem;
		LineRect.left=rcItem.right-m_LineWidth;
		LineRect.right=LineRect.left + m_LineWidth;

		// 转换
		rcfDestRect.X = LineRect.left;
		rcfDestRect.Y = LineRect.top;
		rcfDestRect.Width = m_LineWidth;
		rcfDestRect.Height = LineRect.Height();

		//// 绘制 
		//if (m_pImageLine && !m_DrawRGB && m_pImageLineSep)
		//{
		//	Graphics graphicsDisplay(memDC.GetSafeHdc());
		//	
		//	graphicsDisplay.DrawImage(m_pImageLine, rcfDestRect, 0, 0, m_pImageLine->GetWidth(), m_pImageLine->GetHeight(), UnitPixel);
		//	
		//	graphicsDisplay.DrawImage(m_pImageLineSep, rcfDestRect, 0, 0, m_pImageLineSep->GetWidth(), m_pImageLineSep->GetHeight(), UnitPixel);
		//}
		//else
			memDC.FillSolidRect(LineRect,m_LineColor);

		//// 画分割线
		//image.LoadFromResource(AfxGetResourceHandle(), IDB_HEADERCTRL_END_NORMAL);
		//image.Draw(memDC, rcItem.right - 1, rcItem.top);
		//image.Destroy();

		// 画文字和排序箭头
		UINT uFormat = DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_CENTER;
		if (hditem.fmt & HDF_RIGHT)
		{
			uFormat |= DT_CENTER;//DT_RIGHT;
		}
		else if (hditem.fmt & HDF_CENTER)
		{
			uFormat |= DT_CENTER;
		}

		CRect rcText = rcItem;
		if ((hditem.fmt & HDF_SORTUP) | (hditem.fmt & HDF_SORTDOWN))
		{
			rcText.DeflateRect(5, 1, 13, 1);
			memDC.DrawText(buf, static_cast<int> (_tcslen(buf)), &rcText, uFormat);
		}
		else
		{
			rcText.DeflateRect(5, 1, 5, 1);
			memDC.DrawText(buf, static_cast<int>(_tcslen(buf)), &rcText, uFormat);
		}
	}

	pDC->BitBlt(0,0,rect.Width(),rect.Height(),&memDC,0,0,SRCCOPY);
}
Example #7
0
static  u32 desktop_proc(MSG *msg)
{
	RECT rc;
    HWND hwnd=msg->hwnd;
    switch(msg->Code)
    {
        case    MSG_CREATE:
                wnd=NULL;
           //     printf("Desktop: MSG_CREATE: %08XH.\r\n",hwnd);
                GetClientRect(hwnd,&rc);
             //   GDD_CreateTimer(hwnd,1122,1000,TMR_START);  //循环定时

                break;
                ////
        case    MSG_LBUTTON_DOWN:
         //       printf("Desktop: MSG_LBUTTON_DOWN: %d,%d\r\n",LO16(msg->Param2),HI16(msg->Param2));
                break;
                ////
        case    MSG_LBUTTON_UP:
          //      printf("Desktop: MSG_LBUTTON_UP: %d,%d.\r\n",LO16(msg->Param2),HI16(msg->Param2));
                break;
                ////
        case    MSG_MOUSE_MOVE:
          //      printf("Desktop: MSG_MOUSE_MOVE: %08XH,%d,%d.\r\n",msg->Param1,LO16(msg->Param2),HI16(msg->Param2));
                break;
                ////
        /*
        case    MSG_GET_POS:
                printf("get_pos:%d\r\n",msg->Param1);
                return 0x1234;
                break;
        */
                /////

        case    MSG_TIMER:
                {
                    if(msg->Param1==1)
                    {
                       // InvalidateWindow(hwnd);
                        //PostMessage(hwnd,MSG_PAINT,0,0);
                    }
                }
                break;
                /////

        case    MSG_PAINT:
                {


                    HDC hdc;
                    RECT rc;


                    hdc =BeginPaint(hwnd);

                    GetClientRect(hwnd,&rc);

                    //SetFillColor(hdc,RGB(50,100,200));
                    //FillRect(hdc,&rc);

                    GradientFillRect(hdc,&rc,RGB(120,120,255),RGB(20,20,80),GFILL_U_D);

                    EndPaint(hwnd,hdc);
                }
                break;
        default:
                return DefWindowProc(msg);
    }

    return  0;
}