FontCollection::GetLastStatus method (gdiplusheaders.h)

The FontCollection::GetLastStatus method returns a value that indicates the result of this FontCollection object's previous method call.

Syntax

Status GetLastStatus();

Return value

Type: Status

The FontCollection::GetLastStatus method returns an element of the Status enumeration.

If the previous method invoked on this FontCollection object succeeded, FontCollection::GetLastStatus returns Ok.

If the previous method failed, then FontCollection::GetLastStatus returns one of the other elements of the Status enumeration that indicates the nature of the failure.

Remarks

You can call FontCollection::GetLastStatus immediately after constructing a FontCollection object to determine whether the constructor succeeded. FontCollection::GetLastStatus returns Ok if the constructor succeeded. Otherwise, it returns a value that indicates the nature of the failure.

Note that the implementation of FontCollection::GetLastStatus in the Font and FontCollection classes is different from the implementation of this method in other classes. Also, the implementation of FontCollection::GetLastStatus in the Font class is different from the implementation of FontCollection::GetLastStatus in the FontCollection class.

Examples

The following example creates a PrivateFontCollection object, checks the status of a method call, and, if successful, draws text.

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);
   }
}

Requirements

Requirement Value
Minimum supported client Windows XP, Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header gdiplusheaders.h (include Gdiplus.h)
Library Gdiplus.lib
DLL Gdiplus.dll

See also

FontCollection

PrivateFontCollection

Using Text and Fonts