예제 #1
0
파일: PngButton.cpp 프로젝트: uvbs/V8
void PngButton::DrawBtn()
{
    common::ui::ImageEx* drawImage = GetDrawImage();
    if (drawImage == NULL || m_rcWnd.IsRectEmpty())
    {
        return;
    }

    CRect rect(&m_rcWnd);
    ClientToScreen(&rect);
    //GetWindowRect(&rect);
    CDC *pCDC = GetDC();
    HDC hdcTemp = pCDC->GetSafeHdc();
    HDC hdcMemory = CreateCompatibleDC( hdcTemp );
    HBITMAP hBitMap = CreateCompatibleBitmap( hdcTemp , rect.Width(), rect.Height() );
    HBITMAP hOld = (HBITMAP)SelectObject( hdcMemory , hBitMap );
    Graphics graph( hdcMemory );
    graph.DrawImage(drawImage, 0, 0, rect.Width(), rect.Height());

    if (m_strContent != L"")//有文字内容
    {
        Color conColor;
        conColor.SetFromCOLORREF(m_colCon);
        SolidBrush  brush(conColor);
        FontFamily  fontFamily(m_strConFont.GetBuffer(0));
        Font        font(&fontFamily, m_fontSize, FontStyleBold, UnitPixel);
        PointF      pointF( 0.0f , 0.0f );
        RectF boundRect;
        graph.MeasureString( m_strContent , m_strContent.GetLength() ,&font ,pointF , &boundRect );
        pointF.X = m_rcWnd.left + (m_rcWnd.Width() - boundRect.Width)/2;
        pointF.Y = m_rcWnd.top + (m_rcWnd.Height() - boundRect.Height)/2;
        graph.DrawString( m_strContent , m_strContent.GetLength(), &font, pointF, &brush );
    }

    BOOL bResult = BitBlt( hdcTemp , rect.left , rect.top , rect.Width() , rect.Height() , hdcMemory , 0 , 0 , SRCCOPY );

    POINT ptWinPos = { rect.left,rect.top };
    POINT ptSrc= {0,0};
    SIZE sizeWindow = {rect.Width(), rect.Height() };
    ::UpdateLayeredWindow(m_hWnd, hdcTemp, &ptWinPos, &sizeWindow, hdcMemory, &ptSrc, 0, &m_blend, ULW_ALPHA);
    graph.ReleaseHDC(hdcMemory);
    SelectObject(hdcMemory, hOld);
    DeleteObject(hBitMap);
    DeleteDC(hdcMemory);
    ReleaseDC(pCDC);
}
예제 #2
0
CBackGround::CBackGround()
{

	//파일 위치 지정
	SetCimage(std::make_shared<CImage>());
	WCHAR path[256];
	GetCurrentDirectory(sizeof(path), path);
	WCHAR backGroundPath[256];
	wcscpy_s(backGroundPath, path);
	wcscat_s(backGroundPath, L"/Image/sky.bmp");
	SetCurrentDirectory(backGroundPath);


	SetCurrentPosition(0.0, 0.0);
	
	SetFileLocation(backGroundPath);

	GetDrawImage()->Load(backGroundPath);
	
	
}