c++_获取系统安装字体

2021-03-12 22:29

阅读:547

标签:同步   end   rgba   返回   lease   sys   span   param   col   

//功能函数
#include using namespace std;
vector g_vSysFonts;
INT CALLBACK NEnumFontNameProc(LOGFONT* plf, TEXTMETRIC* /*ptm*/, INT /*nFontType*/, LPARAM lParam/**/)
{
    //同步调用的回调
    vector* sysFonts = (vector*)lParam;
    CString strVal(L"");
    if (sysFonts != NULL)
    {
        strVal = plf->lfFaceName;
        if (strVal.Left(1) != L"@")
        {
            sysFonts->push_back(strVal);
        }
    }
    return TRUE; //EnumFontFamilies 返回值由此回调返回决定
}


void GetSystemFont(HWND& hwnd)
{
    vector vFont;
    HDC hdc = ::GetDC(hwnd);
//    int nRet = ::EnumFontFamilies(hdc, (LPTSTR)NULL, (FONTENUMPROC)NEnumFontNameProc, (LPARAM) & (g_vSysFonts));
    int nRet = ::EnumFonts(hdc, (LPTSTR)NULL, (FONTENUMPROC)NEnumFontNameProc, (LPARAM) & (g_vSysFonts));
    ::ReleaseDC(hwnd, hdc);
}
// 调用函数
GetSystemFont(m_hWnd);
    for (vector::iterator it = g_vSysFonts.begin();it!=g_vSysFonts.end();it++)
    {
        CString css = *it;
        if (css.MakeLower().Find(L"le")!=-1)
        {
            AfxMessageBox(css);
        }
    }

 

c++_获取系统安装字体

标签:同步   end   rgba   返回   lease   sys   span   param   col   

原文地址:https://www.cnblogs.com/leochan007/p/14067559.html


评论


亲,登录后才可以留言!