2013-04-04 112 views
0

我找不到任何DirectX的好網頁源代碼。它一定很簡單,但無法找到如何改變一個簡單的按鈕的字體大小。所以我必須像下面那樣猜測,但不行;DirectX:如何更改按鈕對象的字體大小?

CDXUTDialog g_SampleUI;

g_SampleUI.AddButton(IDC_BUTTON_X2_Y2, L"8", (iX + (2*len)), iY, len, len); 
g_SampleUI.SetFont(IDC_BUTTON_X2_Y2, L"Arial", 32, FW_BOLD ); 

回答

1

CDXUTDialog::SetFont方法does not take an ID作爲第一個參數就像你似乎認爲。

設置按鈕的字體這樣會更有意義(未經測試):

g_SampleUI.SetFont(1, L"Arial", 32, FW_BOLD); 
CDXUTButton *button = g_SampleUI.GetButton(IDC_BUTTON_X2_Y2); 
CDXUTElement *elem = button->GetElement(1); // ..or perhaps GetElement(0) 
elem->SetFont(1); // Set the font for this element to font 1 that we created on 
        // the first line 
g_SampleUI.Refresh();