FontCollection::GetLastStatus 方法 (gdiplusheaders.h)

FontCollection::GetLastStatus 方法返回一个值,该值指示此 FontCollection 对象的上一个方法调用的结果。

语法

Status GetLastStatus();

返回值

类型: 状态

FontCollection::GetLastStatus 方法返回 Status 枚举的元素。

如果对此 FontCollection 对象调用的先前方法成功, 则 FontCollection::GetLastStatus 返回 Ok。

如果前面的方法失败,则 FontCollection::GetLastStatus 返回指示失败性质的 Status 枚举的其他元素之一。

注解

构造 FontCollection 对象后,可以立即调用 FontCollection::GetLastStatus,以确定构造函数是否成功。 如果构造函数成功,则 FontCollection::GetLastStatus 返回 Ok。 否则,它将返回一个值,该值指示失败的性质。

请注意, FontCollection::GetLastStatusFontFontCollection 类中的实现不同于其他类中此方法的实现。 此外,FontCollection::GetLastStatusFont 类中的实现不同于 FontCollection 类中 FontCollection::GetLastStatus 的实现。

示例

以下示例创建 PrivateFontCollection 对象,检查方法调用的状态,如果成功,则绘制文本。

VOID Example_GetLastStatus(HDC hdc)
{
   Graphics graphics(hdc);

   // Create a PrivateFontCollection object, and add three families.
   PrivateFontCollection fontCollection;
   fontCollection.AddFontFile(L"C:\\WINNT\\Fonts\\Arial.ttf");
   fontCollection.AddFontFile(L"C:\\WINNT\\Fonts\\CourBI.ttf");
   fontCollection.AddFontFile(L"C:\\WINNT\\Fonts\\TimesBd.ttf");

   // Create an array to hold the font families, and get the font families of
   // fontCollection.
   FontFamily families[3];
   int numFamilies;
   fontCollection.GetFamilies(3, families, &numFamilies);

   // Verify that the call to GetFamilies was successful.
   Status status = fontCollection.GetLastStatus();

   // If the call was successful, draw text.
   if (status == Ok)
   {
      // Create a Font object from the first FontFamily object in the array.
      Font myFont(&families[0], 16);

      // Use myFont to draw text.
      SolidBrush solidbrush(Color(255, 0, 0, 0));
      WCHAR string[] = L"The call was successful";
      graphics.DrawString(string,
                          23, &myFont, PointF(0, 0), &solidbrush);
   }
}

要求

要求
最低受支持的客户端 Windows XP、Windows 2000 Professional [仅限桌面应用]
最低受支持的服务器 Windows 2000 Server [仅限桌面应用]
目标平台 Windows
标头 gdiplusheaders.h (包括 Gdiplus.h)
Library Gdiplus.lib
DLL Gdiplus.dll

另请参阅

FontCollection

PrivateFontCollection

使用文本和字体