EnumFontFamiliesProc遇到了麻烦 [英] A trouble with EnumFontFamiliesProc

查看:194
本文介绍了EnumFontFamiliesProc遇到了麻烦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!
我有麻烦,请帮帮我!
我是MFC编程的初学者.我已经使用字体系统对程序进行了编码.通过一本书,我知道了使用两个功能列出字体系统的方法:

Hi every body!
I have a trouble, help me please!
I am a beginner in MFC programming. I have coded a progam using font system. Through a book, I knew the way to lists font system by using two functions:

int CALLBACK EnumFontFamExProc(ENUMLOGFONTEX *lpelfe, NEWTEXTMETRICEX *lpntme, DWORD nFontType, LPARAM lParam)
{
    CFontDlg *pWnd = (CFontDlg*) lParam;
    //CFontDlg is the class base on the interface-dialog of my program
    pWnd->m_lbFont.AddString(lpelfe->elfLogFont.lfFaceName);
    //m_lbFont is a variable to control ListBox, which on I want to lists font system
    return 1;
}

void CFontDlg::FillFontList(void)
{
    LOGFONT lf;
    lf.lfCharSet = DEFAULT_CHARSET;
    lstrcpy(lf.lfFaceName, _T(""));
    m_lbFont.ResetContent();
    CClientDC dc(this);
    ::EnumFontFamiliesEx((HDC) dc, &lf, (FONTENUMPROC) EnumFontFamExProc, (LPARAM) this, 0);
}



当我生成程序时,出现错误:
错误C2440:类型转换":无法从重载函数"转换为"FONTENUMPROC"
我不明白发生了什么.请帮帮我!
我的地址:maidinhduong_2179 [at] yahoo.com.vn



When I build the program, there is a error:
error C2440: ''type cast'' : cannot convert from ''overloaded-function'' to ''FONTENUMPROC''
I can''t understand what is happended. Please help me!
My address: maidinhduong_2179 [at] yahoo.com.vn
Thankyou!

推荐答案

有一个现成的MFC类,名为CFontDialog,可以用来从用户那里选择字体,但可以回答您的问题. ..

听起来您的函数定义的签名与函数原型不匹配,这就是为什么错误显示函数重载"的原因.
一种简单的检查方法是在显示的两个位置重命名(名称并不重要)-尝试用MyEnumFontFamExProc或类似名称替换EnumFontFamExProc.
There''s a ready-made MFC class called CFontDialog you can use to get a font selection from the user, but to answer your question...

It sounds like the signature of your function definition doesn''t match a function prototype, which is why the error says ''overloaded-function''.

A simple way to check would be to rename it in the two places you have shown (the name doesn''t really matter) - try replacing EnumFontFamExProc with MyEnumFontFamExProc or something similar.


这是唯一定义EnumFontFamExProc的地方吗?似乎编译器从某个地方有另一个定义;也许您可以发布更多代码,包括CFontDlg类定义.

ps我还将您的代码放在< pre></pre>标签以使其更具可读性.
Is this the only place that EnumFontFamExProc is defined? It looks as though the compiler has another definition from somewhere; perhaps you could post some more of the code, including the CFontDlg class definition.

ps I also put your code in <pre></pre> tags to make it more readable.


这篇关于EnumFontFamiliesProc遇到了麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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