SetFont保持单一类 [英] SetFont to maintain in single class

查看:138
本文介绍了SetFont保持单一类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我的应用程序有4个对话框。在每个对话框中维护控件的字体。



现在我想将所有字体移动到单个方法从那里我想申请字体。

任何人都可以给我建议如何做。

Hi my application is having 4 dialogs.Am maintaining the font for the controls in each dialog.

Now i wanted to move all the font to a single method and from there i wanted to apply the fonts.
Can any one give me suggestion how to do it.

推荐答案





我可以看到没有问题。只需创建一个方法,它将接受您想要设置字体的compopmnent的ID。在方法中,您为给定的组件/窗口加载/创建字体并将其设置为该组件。



Hi,

I can see no trouble. just create a methos that will accepst a an ID of the compopmnent to which you want to set the font. The in the method, you load/create the font for given component/window and set it to that component.

void CMyDialogWindow::SetComponentFont(intiComponentId)
{
   CWnd* pComponent = this->GetDlgItem();
   if (pComponent != NULL)
   {
       // here you load or create some Font
       CFont* pFont = CreateOrLoadMyWonderfulFont();

       if (pFont != NULL)
       {
          pComponent->SetFont(pFont);
       }
   }
}



有关CWnd :: GetDlgItem(int nId)的更多信息,请参阅 MSDN 。有关CWnd :: SetFont(CFont * pFont)的更多信息,请参阅 MSDN



希望这会有所帮助。



祝你好运,

JK


For more info about the CWnd::GetDlgItem(int nId) see MSDN. For more info about the CWnd::SetFont(CFont* pFont) see MSDN.

Hope this helps.

Best regards,
J.K.


这篇关于SetFont保持单一类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆