Listing 9

using namespace win32::gui::draw;

// pointer to a surface
ptr<> p = ...;
// pointer to a text surface
ptr<surface::text> txt = ...;
// Casting
using namespace 
    win32::gui::draw::surface;
// it throws if the cast fails
ptr<html_text> html = cast<html_text>(p);
// html2 is null, if the cast fails

ptr<html_text> html2 = try_cast<html_text>(p);