473,288 Members | 1,718 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,288 software developers and data experts.

Moved code won't compile

I had this code previously:

void App::FillFontBox(HWND PrefsBox)
{
[snipped]

EnumFontFamilies(hdc,(LPCTSTR)NULL,(FONTENUMPROC)E numFontNamesProc,(long)this);

[snipped]

sort(FontNames.begin(), FontNames.end(), CaselessCmp);

[snipped]

return;
}

int CALLBACK App::EnumFontNamesProc(ENUMLOGFONT FAR *lpelf,
NEWTEXTMETRICFAR*lpntm,intFontType, LPARAM lParam)

bool App::CaselessCmp(const string& s1, const string& s2)

It compiled fine. (Apologies for the window code, but I'm assuming this
is a C++ problem, rather than an OS specific one.)

I moved much of the code from FillFontBox, and the CALLBACK (__stdcall)
and predicate functions into an existing class:

vector<stringClass_Font::GetTypeFaces()
{
[snipped]

EnumFontFamilies(hdc,(LPCTSTR)
NULL,(FONTENUMPROC)EnumFontNamesProc, (long)NULL);

[snipped]

sort(TypefaceNames.begin(), TypefaceNames.end(), CaselessCmp);

return TypefaceNames;
}

int CALLBACK Class_Font::EnumFontNamesProc(ENUMLOGFONT FAR *lpelf,
NEWTEXTMETRIC FAR *lpntm, int FontType, LPARAM lParam)

bool Class_Font::CaselessCmp(const string& s1, const string& s2)

Now the compiler wants me to use "&Class_Font::CaselessCmp" and when
passing EnumFontNamesProc the compiler gives me "error C2440: 'type
cast' : cannot convert from 'overloaded-function' to 'FONTENUMPROC'"

There's only one EnumFontNamesProc.

Anyone know what's going on here?

Thank you
--
Derek
Nov 3 '07 #1
1 1800
* DerekBaker:
* DerekBaker:
>I had this code previously:

void App::FillFontBox(HWND PrefsBox)
{
[snipped]

EnumFontFamilies(hdc,(LPCTSTR)NULL,(FONTENUMPROC) EnumFontNamesProc,(long)this);
[snipped]
sort(FontNames.begin(), FontNames.end(), CaselessCmp);

[snipped]

return;
}

int CALLBACK App::EnumFontNamesProc(ENUMLOGFONT FAR *lpelf,
NEWTEXTMETRICFAR*lpntm,intFontType, LPARAM lParam)

bool App::CaselessCmp(const string& s1, const string& s2)

It compiled fine. (Apologies for the window code, but I'm assuming
this is a C++ problem, rather than an OS specific one.)

I moved much of the code from FillFontBox, and the CALLBACK
(__stdcall) and predicate functions into an existing class:

vector<stringClass_Font::GetTypeFaces()
{ [snipped]
EnumFontFamilies(hdc,(LPCTSTR)
NULL,(FONTENUMPROC)EnumFontNamesProc, (long)NULL);
[snipped]
sort(TypefaceNames.begin(), TypefaceNames.end(), CaselessCmp);

return TypefaceNames;
}

int CALLBACK Class_Font::EnumFontNamesProc(ENUMLOGFONT FAR *lpelf,
NEWTEXTMETRIC FAR *lpntm, int FontType, LPARAM lParam)

bool Class_Font::CaselessCmp(const string& s1, const string& s2)

Now the compiler wants me to use "&Class_Font::CaselessCmp" and when
passing EnumFontNamesProc the compiler gives me "error C2440: 'type
cast' : cannot convert from 'overloaded-function' to 'FONTENUMPROC'"

There's only one EnumFontNamesProc.

Anyone know what's going on here?

Thank you

Well it wouldn't take EnumFontNamesProc, because I didn't declare it
static.

Now it won't take the predicate!

sort(TypefaceNames.begin(), TypefaceNames.end(), &Class_Font::CaselessCmp);

won't call

bool Class_Font::CaselessCmp(const string& s1, const string& s2)
{[snipped]}

even though the compiler suggests it.

Output [apologies for the length]:
[snipped]

Works now that CasslessCmp is static. That'll teach not to copy and paste, especially when I've got
a headache!.
--
Derek
Nov 3 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: lkrubner | last post by:
I wrote a PHP content management system and it worked fine on old servers. I just moved it to a new server on Rackspace. I'm trying to debug. At the top of the first file (index.php) I need to...
13
by: AFKAFB | last post by:
Hi Sometimes when i edit previously saved VBA code e.g. To update field names etc the revised code does not work. Even if i copy and paste in a previous version it does not work. The only...
13
by: Skybuck Flying | last post by:
Hi, I would like to split main.c which contains all code into the following Step 1. Machine.h Step 2. drand.h and drand.c Step 3. nrand.h and nrand.c Main.c then only contains some test...
5
by: n_o_s_p_a__m | last post by:
Can't compile. Does this mean that all functions that throw exceptions must be of return type void? examples: // won't compile: "not all code paths return a value" public override int Run() {...
13
by: R Reyes | last post by:
is there a way to avoid the validateRequest error page in my code behind file? i can't seem to find a way to handle the error w/o an error code or exception being thrown... i am NOT looking for...
10
by: Sourcerer | last post by:
I wrote this very simple code in .NET VC++. I compiled it on my system, and tried to run it on my friend's computer (he doesn't have the compiler). We both have Windows XP Professional. I have .NET...
1
by: mark4asp | last post by:
I moved a page to another web-site and now it's broke! I had 5 pages in their own web-site. These pages have now been moved to another web-site. Everything is fine except that one of the pages,...
8
by: mohammaditraders | last post by:
#include <iostream.h> #include <stdlib.h> #include <conio.h> #include <string.h> class Matrix { private : int numRows, numCols ; int elements ;
1
by: Alex | last post by:
Hi Everyone, To better organize my code I created to Folders in Visual Studio 2005, one for Forms and one for Logic... then I moved the .vb files into the appropriate folders. It worked great...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.