FontCollection::GetLastStatus 方法 (gdiplusheaders.h)

FontCollection::GetLastStatus 方法會傳回值,指出這個 FontCollection 物件先前的方法呼叫的結果。

Syntax

Status GetLastStatus();

傳回值

類型: 狀態

FontCollection::GetLastStatus 方法會傳回 Status 列舉的元素。

如果在此 FontCollection 物件上叫用的上一個方法成功, FontCollection::GetLastStatus 會傳回 Ok。

如果先前的方法失敗, 則 FontCollection::GetLastStatus 會傳回 Status 列舉的其中一個其他元素,指出失敗的本質。

備註

建構 FontCollection 物件之後,您可以立即呼叫 FontCollection::GetLastStatus,以判斷建構函式是否成功。 FontCollection::GetLastStatus 如果建構函式成功,則會傳回 Ok。 否則,它會傳回值,指出失敗的本質。

請注意,Font FontCollection 類別中 FontCollection::GetLastStatus 的實作與其他類別中此方法的實作不同。 此外,Font 類別中 FontCollection::GetLastStatus 的實作與 FontCollection::GetLastStatus 在 FontCollection 類別中的實不同。

範例

下列範例會建立 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)
程式庫 Gdiplus.lib
Dll Gdiplus.dll

另請參閱

FontCollection

PrivateFontCollection

使用文字和字型