Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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);
}


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!
Posted
Updated 19-Jan-10 23:26pm
v3

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.
 
Share this answer
 
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900