locked
Is it possible to draw a control across C++ WinRT component to HTML5?

    Question

  • We know we can draw something in a web page through plugin which is designed by c++. Now I have a Js project and invoke a C++ WinRT component. Can I draw something in a page through c++ code rather than js code? Thanks!
    Friday, August 10, 2012 6:47 AM

Answers

  • You will likely need to rewrite your drawing code using Direct2D. It is likely your existing ATL code uses unsupported drawing technologies (GDI, GDI+, etc.) Depending on what exactly it does you may be able to keep the logic, but the details likely need to change.

    See Creating Windows Runtime Components in C++ for information on how to write a Windows Runtime Component. I'm not aware of any samples which specifically return bitmap data.

    --Rob

    • Marked as answer by Jesse Jiang Monday, August 20, 2012 6:01 AM
    Monday, August 13, 2012 5:03 AM
    Owner

All replies

  • You cannot draw directly on an HTML page from C++. You could generate a bitmap from C++ and then pass that to JS code to draw it on the page.

    --Rob

    Friday, August 10, 2012 6:56 AM
    Owner
  • Thanks Rob!

    So you mean I only draw something in JS. I also have question as below:

     How about using directX? Can it work?


    • Edited by Dinowy Friday, August 10, 2012 7:25 AM
    Friday, August 10, 2012 7:20 AM
  • You cannot draw directly on your HTML page from C++.

    You could use DirectX to render a bitmap and then pass that to your JavaScript code to draw it on the page.

    You would need to add your controls from JavaScript.

    --Rob

    Friday, August 10, 2012 7:25 AM
    Owner
  • OK, got it.

    I have a win32 JS project and I can install a plugin which was used ATL to draw something on a page. Now I want to port it to new windows 8 style . I'v noticed ATL is not fully supported in windows 8. How can I do ?

    Friday, August 10, 2012 7:32 AM
  • Hi Rob, do you know any samples similar with this situation?

    OR when I press on a page, the c++ component can listen this event and then draw a bitmap with background task?

    Thanks!

    Monday, August 13, 2012 2:42 AM
  • You will likely need to rewrite your drawing code using Direct2D. It is likely your existing ATL code uses unsupported drawing technologies (GDI, GDI+, etc.) Depending on what exactly it does you may be able to keep the logic, but the details likely need to change.

    See Creating Windows Runtime Components in C++ for information on how to write a Windows Runtime Component. I'm not aware of any samples which specifically return bitmap data.

    --Rob

    • Marked as answer by Jesse Jiang Monday, August 20, 2012 6:01 AM
    Monday, August 13, 2012 5:03 AM
    Owner