473,725 Members | 2,271 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Moved code won't compile

I had this code previously:

void App::FillFontBo x(HWND PrefsBox)
{
[snipped]

EnumFontFamilie s(hdc,(LPCTSTR) NULL,(FONTENUMP ROC)EnumFontNam esProc,(long)th is);

[snipped]

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

[snipped]

return;
}

int CALLBACK App::EnumFontNa mesProc(ENUMLOG FONT FAR *lpelf,
NEWTEXTMETRICFA R*lpntm,intFont Type, LPARAM lParam)

bool App::CaselessCm p(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<stringCl ass_Font::GetTy peFaces()
{
[snipped]

EnumFontFamilie s(hdc,(LPCTSTR)
NULL,(FONTENUMP ROC)EnumFontNam esProc, (long)NULL);

[snipped]

sort(TypefaceNa mes.begin(), TypefaceNames.e nd(), CaselessCmp);

return TypefaceNames;
}

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

bool Class_Font::Cas elessCmp(const string& s1, const string& s2)

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

There's only one EnumFontNamesPr oc.

Anyone know what's going on here?

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

void App::FillFontBo x(HWND PrefsBox)
{
[snipped]

EnumFontFamili es(hdc,(LPCTSTR )NULL,(FONTENUM PROC)EnumFontNa mesProc,(long)t his);
[snipped]
sort(FontNames. begin(), FontNames.end() , CaselessCmp);

[snipped]

return;
}

int CALLBACK App::EnumFontNa mesProc(ENUMLOG FONT FAR *lpelf,
NEWTEXTMETRICF AR*lpntm,intFon tType, LPARAM lParam)

bool App::CaselessCm p(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<stringC lass_Font::GetT ypeFaces()
{ [snipped]
EnumFontFamilie s(hdc,(LPCTSTR)
NULL,(FONTENUM PROC)EnumFontNa mesProc, (long)NULL);
[snipped]
sort(TypefaceNa mes.begin(), TypefaceNames.e nd(), CaselessCmp);

return TypefaceNames;
}

int CALLBACK Class_Font::Enu mFontNamesProc( ENUMLOGFONT FAR *lpelf,
NEWTEXTMETRI C FAR *lpntm, int FontType, LPARAM lParam)

bool Class_Font::Cas elessCmp(const string& s1, const string& s2)

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

There's only one EnumFontNamesPr oc.

Anyone know what's going on here?

Thank you

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

Now it won't take the predicate!

sort(TypefaceNa mes.begin(), TypefaceNames.e nd(), &Class_Font::Ca selessCmp);

won't call

bool Class_Font::Cas elessCmp(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
1388
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 include a file. The file won't be included. In the code below, $success remains false. I've checked a million times and the file is there. error_reporting(E_ALL);
13
2046
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 solution seems to be to delete the existing code, re-type ir word for word and hey presto it works. Of course you might think typo or something but its like Access seems
13
2632
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 code.
5
6757
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() { throw new Exception("exception thrown"); }
13
7579
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 a link that explains what it does and what it doesn't do OR the pros/cons, as i've already read through many of those. i just want to know if i can code some sort of exception to catch for it so that the ugly yellow/white microsoft generic page...
10
1835
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 framework 2.0, and he had 1.0 and it didn't work; then he installed 2.0 and it still didn't work; so he tried with 2.1 and it didn't work, then 3.0 and nothing still worked. I have Intel Centrino Mobile (laptop computer), and he has Intel Pentium...
1
2704
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, which I had trouble with in the past (i.e. same problem), is now partly broke. The paging no longer fully works in the gridview. The gvAwarded_RowDataBound code works to load the ddlPager with the correct number of pages.
8
2337
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
1079
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 for all but two forms, which now Visual Studio has unlinked the Designer.vb file, .resx file, and .vb files. So now when I double-click on the .vb file for the form, it's just blank. How to I get VB to put these back together???
0
8889
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9179
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8099
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3228
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2637
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.