DirectX:如何更改按钮对象的字体大小?

时间:2013-04-04 07:16:09

标签: c++ c visual-c++ 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  );

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 个答案:

答案 0 :(得分: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();