字体都是得到的,怎么样才能在一个HDC上写一个比如是宋体的字符.还有怎么样在对话框上显示一个宋体的字呢.对话框上显示的这个字的字体可以改变,在对话框上有个一选择字体的按钮,选了什么字体就用什么字体显示.

解决方案 »

  1.   

    use a place holder static, then draw the expected font urself within it.
      

  2.   

    derive a class from CStatic with new handler to WM_PAINT, create a instance in ur dialog contructor. while initializing dialog, subclass the static control u put into the dialog to hold place in the resource editor.
      

  3.   

    OnInitDialog()
    {
     m_MyShowFontCtrl.SubclassDlgItem(IDC_PLACEHOLDER, this);
     m_MyShowFontCtrl.SetText("AAA")...etc
    }
      

  4.   

    OnButton()
    {
    LOGFONT lf;
    CFongDialog dlg;
    //弹出对话框,可以自己选择宋体等
    if (dlg.DoModal() == IDOK)
    {
       dlg.GetCurrentFont(&lf);
    }
    HFONT hFont = ::CreateFontIndirect(&lf);
    HDC hdc = ...;//你自己的HDC;
    HFONT hOld = ::SelectObject(hdc,hFont);
    ::DrawText(....);//写字,参考MSDN;
    ::SelectObject(hdc,hOld);
    ...
      

  5.   

    ::DrawText(HDC....);//写字,参考MSDN;
    ::SelectObject(hdc,hOld);