Any one who can help me.
I can't see the OSD text with the following codes!
I don't know what is wrong with the codes.
Code: Select all
CWnd *pWnd = CWnd::FromHandle(hwndDD);
bmSurface = (HBITMAP)SendMessage(hwndDD, WM_MODULE_MSG, DDMODAPI_OSD_GET_SURFACE_BITMAP, surface_id); // get bitmap
WCHAR* m_sshow ;
m_sshow = L"This is my text";
HDC hdcTemp=::GetDC(NULL);
HDC m_hdcMemory =CreateCompatibleDC(hdcTemp);
SelectObject(m_hdcMemory,bmSurface);
Graphics g(m_hdcMemory);
g.SetSmoothingMode(SmoothingModeAntiAlias);
POINT pt,pos;
pt.x=0;
pt.y=0;
RECT rt;
pWnd->GetWindowRect(&rt);
pos.x = rt.left;
pos.y = rt.top;
SIZE SZ;
SZ.cx=800;
SZ.cy=80;
BLENDFUNCTION b;
b.AlphaFormat =AC_SRC_ALPHA;
b.BlendFlags=0;
b.BlendOp=AC_SRC_OVER;
b.SourceConstantAlpha=255;
FontFamily font(L"宋体");
GraphicsPath path,path2;
path.AddString(
m_sshow,
-1,
&font,
FontStyleRegular,
72,
Rect(5, 5, 500, 100),
NULL);
path2.AddString(
m_sshow,
-1,
&font,
FontStyleRegular,
72,
Rect(8, 8, 500, 100),
NULL);
SolidBrush byy(Color(128,0, 0, 0));
LinearGradientBrush bin(PointF(0,0),PointF(0,80),Color(255,0,0,255),Color(255,0,255,0));;//图形填充画刷
Pen pout(Color(128, 255, 255,255),1.0f);
Pen pyy(Color(100, 0, 0,0),2.0f);
g.FillPath(&byy,&path2);
g.DrawPath(&pyy, &path2);
g.FillPath(&bin,&path);
g.DrawPath(&pout, &path);
::UpdateLayeredWindow( hwndDD,pWnd->GetDC()->m_hDC,&pos,
&SZ,m_hdcMemory,&pt,0,&b,2);
SendMessage(hwndDD, WM_MODULE_MSG, DDMODAPI_OSD_REPAINT_SURFACE, surface_id);
SendMessage(hwndDD, WM_MODULE_MSG, DDMODAPI_OSD_SHOW_SURFACE, surface_id);