locked
Can TextRenderer.MeasureText method used in Win8 Metro app development.

Answers

  • GDI is not available.

    You can use Xaml for high level UI or DirectX for low level. You can mix them using DirectX and Xaml interop to either include DirectX renderings in a Xaml page or to place a Xaml overlay on top of a DirectX rendering.

    Xaml doesn't provide a way to measure a string, although you can get the size of an element such as a TextBox. Depending on why you need the length this may or may not be sufficient for you.

    I strongly recommend you go through the getting started documentation before starting to build your app so you can get an idea of what resources, functions, and classes are available to you. The API reference includes links to the available .Net, Win32 and COM API, as well as the new Windows Runtime API.

    --Rob

    • Marked as answer by Dawei Cheng Friday, August 10, 2012 5:46 AM
    Friday, August 10, 2012 2:29 AM
    Owner

All replies

  • No. System.Windows.Forms is not available. Even if it were, you cannot directly call .Net classes from a C++/Cx project.

    You can measure text with DirectWrite. See the IDWriteTextLayout interface

    --Rob

    • Marked as answer by Dawei Cheng Friday, August 10, 2012 1:58 AM
    • Unmarked as answer by Dawei Cheng Friday, August 10, 2012 2:00 AM
    Thursday, August 09, 2012 10:33 PM
    Owner
  • This Interface need use DirectX, Is there any API can work without using DX. such as GDI? I'm developing Metro app in C++. 

    See 

    IDWriteTextRenderer declares methods for drawing a glyph run, underline, strikethrough and inline objects. It is up to the application to implement these methods. Creating a custom text renderer allows the application to apply additional effects when rendering text, such as a custom fill or outline.

    Using a custom text renderer also enables you to render using another technology, such as GDI.

    Friday, August 10, 2012 2:06 AM
  • GDI is not available.

    You can use Xaml for high level UI or DirectX for low level. You can mix them using DirectX and Xaml interop to either include DirectX renderings in a Xaml page or to place a Xaml overlay on top of a DirectX rendering.

    Xaml doesn't provide a way to measure a string, although you can get the size of an element such as a TextBox. Depending on why you need the length this may or may not be sufficient for you.

    I strongly recommend you go through the getting started documentation before starting to build your app so you can get an idea of what resources, functions, and classes are available to you. The API reference includes links to the available .Net, Win32 and COM API, as well as the new Windows Runtime API.

    --Rob

    • Marked as answer by Dawei Cheng Friday, August 10, 2012 5:46 AM
    Friday, August 10, 2012 2:29 AM
    Owner