locked
Direct2D -> How to use ID2D1DCRenderTarget objects for render content to a printer device context. RRS feed

  • Question

  • Hello everyone .
    I want to use ID2D1DCRenderTarget objects for render content to a printer device context.
    The following code is wrong , What should I do ? Thanks.
     

     HRESULT  hr;

     extern  HDC  hPrinterDC ; // a valid printer device context.

     extern  ID2D1Factory2  * m_d2dFactory; // a valid object

     

     D2D1_RENDER_TARGET_PROPERTIES rtPro_Printer;

     rtPro_Printer.type = D2D1_RENDER_TARGET_TYPE_DEFAULT;
     rtPro_Printer.dpiX = 0;
     rtPro_Printer.dpiY = 0;
     rtPro_Printer.usage = D2D1_RENDER_TARGET_USAGE_GDI_COMPATIBLE;
     rtPro_Printer.minLevel = D2D1_FEATURE_LEVEL_DEFAULT;
     rtPro_Printer.pixelFormat = D2D1::PixelFormat(
                                                                                  (DXGI_FORMAT)DXGI_FORMAT_B8G8R8A8_UNORM,
                                                                                  D2D1_ALPHA_MODE_IGNORE
                                                                              );

     CComPtr<ID2D1DCRenderTarget>    m_d2dDCRT;

     hr = m_d2dFactory->CreateDCRenderTarget(&rtPro_Printer, &m_d2dDCRT);
     assert(S_OK == hr);

     RECT rect = { 100,100,800,800};

          

            //   This  is the wrong code

            hr = m_d2dDCRT->BindDC(hPrinterDC, &rect);  

            //  it returns an HRESULT error code.     "One or more arguments are invalid"

    • Moved by Mattew Wu Monday, December 5, 2016 5:19 AM not Dev Center issue
    Sunday, December 4, 2016 5:26 AM

Answers

  • Hello,

    This forum is used to discuss the question regarding Dev Center account, so I will move your thread in order that your post may appear in correct scenario.

    Thanks for your understanding.

    Best regards,

    Mattew Wu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by w_20161204 Monday, December 5, 2016 1:36 PM
    Monday, December 5, 2016 5:19 AM

All replies

  • Hello,

    This forum is used to discuss the question regarding Dev Center account, so I will move your thread in order that your post may appear in correct scenario.

    Thanks for your understanding.

    Best regards,

    Mattew Wu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by w_20161204 Monday, December 5, 2016 1:36 PM
    Monday, December 5, 2016 5:19 AM
  • Check the DirectX forum at http://xboxforums.create.msdn.com/forums/76.aspx


    Visual C++ MVP

    Monday, December 19, 2016 12:30 PM