How can OSD show text with c++

Module API help / support section for programmers.

Moderators: FredB, X05, Dreamer

zixi0007
Just popping in
Posts: 4
Joined: Tue May 21, 2013 6:08 am

How can OSD show text with c++

Postby zixi0007 » Wed May 22, 2013 7:40 am

This is my code of osd show. But I don't know how to do.
Any one who can help me!

Code: Select all

TOSDSurface osd;
osd.dwSize = sizeof(osd);
osd.dwHeight = 50;
osd.dwWidth = 400;
osd.dwTop = 1;
osd.dwLeft = 1;
osd.Transparency = 1;
int hOSD = SendMessage(hwndDD, WM_MODULE_MSG, DDMODAPI_OSD_CREATE_SURFACE, (LPARAM)&osd);
 
HBITMAP bmSurface = (HBITMAP)SendMessage(hwndDD, WM_MODULE_MSG, DDMODAPI_OSD_GET_SURFACE_BITMAP, hOSD); // get bitmap
 
 SendMessage(hwndDD, WM_MODULE_MSG, DDMODAPI_OSD_SHOW_SURFACE, hOSD);

User avatar
rel
relocation
Posts: 1999
Joined: Fri Jun 16, 2006 9:50 am

Re: How can OSD show text with c++

Postby rel » Sat May 25, 2013 4:29 am

you need to get a compatible DC for HBITMAP bmSurface
and then draw on that with Windows GDI functions
DVB Dream - because I have to dream about having time to code it
zixi0007
Just popping in
Posts: 4
Joined: Tue May 21, 2013 6:08 am

Re: How can OSD show text with c++

Postby zixi0007 » Wed Jun 05, 2013 7:18 am

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);

User avatar
rel
relocation
Posts: 1999
Joined: Fri Jun 16, 2006 9:50 am

Re: How can OSD show text with c++

Postby rel » Wed Jun 05, 2013 12:49 pm

send me your code if you would like, I'll try to compile and help here.
DVB Dream - because I have to dream about having time to code it

Return to “Module / Plugin Programming”

Who is online

Users browsing this forum: No registered users and 2 guests