void CMFCApplication1Dlg::DrawUI()
{
CRect rect;
GetWindowRect(rect);
HDC dc = ::GetDC(m_hWnd);
HDC memdc = CreateCompatibleDC(dc);
HDC bmpdc = CreateCompatibleDC(dc);
Gdiplus::Bitmap* bmp = (Gdiplus::Bitmap*)img;
BITMAPINFO bitmapinfo;
bitmapinfo.bmiHeader.biBitCount = 32;
bitmapinfo.bmiHeader.biClrImportant = 0;
bitmapinfo.bmiHeader.biClrUsed = 0;
bitmapinfo.bmiHeader.biCompression = BI_RGB;
bitmapinfo.bmiHeader.biWidth = rect.Width();
bitmapinfo.bmiHeader.biHeight = rect.Height();
bitmapinfo.bmiHeader.biPlanes = 1;
bitmapinfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bitmapinfo.bmiHeader.biSizeImage = bitmapinfo.bmiHeader.biWidth*bitmapinfo.bmiHeader.biHeight*bitmapinfo.bmiHeader.biBitCount/8;
bitmapinfo.bmiHeader.biXPelsPerMeter = 0;
bitmapinfo.bmiHeader.biYPelsPerMeter = 0;
HBITMAP hbitmap = ::CreateDIBSection(memdc,&bitmapinfo,DIB_RGB_COLORS,NULL,0,0);
HBITMAP oldbit = (HBITMAP)::SelectObject(memdc,hbitmap);
Graphics g(memdc);
CRect r;
GetWindowRect(r);
Bitmap* bmp1 = (Bitmap*)img;
HBITMAP hBitmap=NULL;
Color color(255,255,255,255);
bmp1->GetHBITMAP(color,&hBitmap);
::SelectObject(bmpdc,hBitmap);
BLENDFUNCTION blendFunc32bpp;
blendFunc32bpp.AlphaFormat = AC_SRC_ALPHA;
blendFunc32bpp.BlendFlags = 0;
blendFunc32bpp.BlendOp = AC_SRC_OVER;
blendFunc32bpp.SourceConstantAlpha = 200;
::SelectObject(bmpdc,hbitmap);
AlphaBlend(memdc,0,0,r.Width(),r.Height(),bmpdc,0,0,img->GetWidth(),img->GetHeight(),blendFunc32bpp);
Graphics graphics(memdc);
Gdiplus::SolidBrush blackBrush(Color(255, 0, 0, 0));
// Create the RectF object that defines the ellipse.
RectF ellipseRect(0.0f, 0.6f, 1200.8f, 1100.9f);
// Fill the ellipse.
//graphics.FillEllipse(&blackBrush, ellipseRect);
// Create a string.
CString string = L"发生的发的发生的发的是发生的发生";
// Initialize arguments.
Gdiplus::Font myFont(L"Arial", 16);
Gdiplus::PointF origin(0.0f, 0.0f);
// SolidBrush blackBrush(Color(255, 0, 0, 0));
// Draw string.
graphics.DrawString(
string,
string.GetLength(),
&myFont,
origin,
&blackBrush);
CPoint DestPt(0,0);
CSize psize(rect.Width(),rect.Height());
blendFunc32bpp.SourceConstantAlpha =255;
::UpdateLayeredWindow(m_hWnd,dc,NULL,&psize,memdc,&DestPt,0,&blendFunc32bpp,ULW_ALPHA);
SelectObject(memdc,oldbit);
::ReleaseDC(m_hWnd,memdc);
}
{
CRect rect;
GetWindowRect(rect);
HDC dc = ::GetDC(m_hWnd);
HDC memdc = CreateCompatibleDC(dc);
HDC bmpdc = CreateCompatibleDC(dc);
Gdiplus::Bitmap* bmp = (Gdiplus::Bitmap*)img;
BITMAPINFO bitmapinfo;
bitmapinfo.bmiHeader.biBitCount = 32;
bitmapinfo.bmiHeader.biClrImportant = 0;
bitmapinfo.bmiHeader.biClrUsed = 0;
bitmapinfo.bmiHeader.biCompression = BI_RGB;
bitmapinfo.bmiHeader.biWidth = rect.Width();
bitmapinfo.bmiHeader.biHeight = rect.Height();
bitmapinfo.bmiHeader.biPlanes = 1;
bitmapinfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bitmapinfo.bmiHeader.biSizeImage = bitmapinfo.bmiHeader.biWidth*bitmapinfo.bmiHeader.biHeight*bitmapinfo.bmiHeader.biBitCount/8;
bitmapinfo.bmiHeader.biXPelsPerMeter = 0;
bitmapinfo.bmiHeader.biYPelsPerMeter = 0;
HBITMAP hbitmap = ::CreateDIBSection(memdc,&bitmapinfo,DIB_RGB_COLORS,NULL,0,0);
HBITMAP oldbit = (HBITMAP)::SelectObject(memdc,hbitmap);
Graphics g(memdc);
CRect r;
GetWindowRect(r);
Bitmap* bmp1 = (Bitmap*)img;
HBITMAP hBitmap=NULL;
Color color(255,255,255,255);
bmp1->GetHBITMAP(color,&hBitmap);
::SelectObject(bmpdc,hBitmap);
BLENDFUNCTION blendFunc32bpp;
blendFunc32bpp.AlphaFormat = AC_SRC_ALPHA;
blendFunc32bpp.BlendFlags = 0;
blendFunc32bpp.BlendOp = AC_SRC_OVER;
blendFunc32bpp.SourceConstantAlpha = 200;
::SelectObject(bmpdc,hbitmap);
AlphaBlend(memdc,0,0,r.Width(),r.Height(),bmpdc,0,0,img->GetWidth(),img->GetHeight(),blendFunc32bpp);
Graphics graphics(memdc);
Gdiplus::SolidBrush blackBrush(Color(255, 0, 0, 0));
// Create the RectF object that defines the ellipse.
RectF ellipseRect(0.0f, 0.6f, 1200.8f, 1100.9f);
// Fill the ellipse.
//graphics.FillEllipse(&blackBrush, ellipseRect);
// Create a string.
CString string = L"发生的发的发生的发的是发生的发生";
// Initialize arguments.
Gdiplus::Font myFont(L"Arial", 16);
Gdiplus::PointF origin(0.0f, 0.0f);
// SolidBrush blackBrush(Color(255, 0, 0, 0));
// Draw string.
graphics.DrawString(
string,
string.GetLength(),
&myFont,
origin,
&blackBrush);
CPoint DestPt(0,0);
CSize psize(rect.Width(),rect.Height());
blendFunc32bpp.SourceConstantAlpha =255;
::UpdateLayeredWindow(m_hWnd,dc,NULL,&psize,memdc,&DestPt,0,&blendFunc32bpp,ULW_ALPHA);
SelectObject(memdc,oldbit);
::ReleaseDC(m_hWnd,memdc);
}