Click here to Skip to main content
15,884,537 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have downloaded the source code for Joseph M Newcomer's Metafile Explorer utility from his web site at:

http://www.flounder.com/metafileexplorer.htm

but cannot get it to build successfully with Visual Studio 2010. This is a C++ project. Has anyone else had success doing this? I do not have access to an earlier version of VS to try there, and I don't know what version it was originally built with when it was written. Maybe this built successfully with an earlier version when the code was written but doesn't with a newer version of VS?

I am a novice to using Visual Studio, so I realize it's possible I may be overlooking the obvious. But currently I am getting the following compile error:

Error C2664: 'TreeDecode::FormatEXTLOGPEN': cannot convert parameter 1 from 'EXTLOGPEN32 *' to 'const EXTLOGPEN *'.

What needs to be done to allow this to build with Visual Studio 2010?

By the way, this is a brilliant EMF debugger utility. I've used it for years. I recently downloaded the source application from Mr. Newcomer's web site as a way to see how difficult it would be to modify this utility to handle GDI+ and process EMF+ records. What I need is a modified version of this utility that also supports EMF+.

Has anyone done a successful modification of this utility or know of any others that will parse an EMF file and display EMF, EMF Plus, or EMF Dual language records that reside in the file while allowing you to visually see the output of the file being generated while single stepping thru it?

By the way, I did email Mr. Newcomer back in May. He indicated he'd take a look but I haven't heard back since. I assume he's been busy with other things and hasn't had a chance to look at this. In the meantime, I thought I'd ask to see if anyone else has had problems compiling this application with VS 2010.
Posted
Updated 21-Jul-20 10:36am
Comments
Christian Graus 23-Jul-12 18:05pm    
The odds of anyone else here using it, are low. Did you read the docs on the two classes ? I think it's a 32/64 bit issue, at a guess.
Sergey Alexandrovich Kryukov 23-Jul-12 23:57pm    
Is the code giving you this compilation message yours, or is it a library's?
The error if very explainable -- apparently, non-const point should not be cast to const.
--SA

Please see my comment — did you get it? The problem is quite apparent: C++ does not allow implicit cast from non-constant pointer to a constant one. Such cast would imply that the object pointed by the constant pointer cannot change, but in fact, it can, as it is also pointed by the non-constant pointer used as a source pointer in your assignment operation.

As a work-around, C++ reserves the const_cast<> operator. Please see:
http://msdn.microsoft.com/en-us/library/bz6at95h%28v=vs.100%29.aspx[^],
http://www.cplusplus.com/doc/tutorial/typecasting/[^].

You should use it with great care and preferably avoid using it, if you can obtain a constant pointer in first place (the source of assignment, right-part of assignment), or use a non-constant pointer as the left part of assignment (target of assignment). If you still need to use the const_cast<> operator, you should be sure that the object pointed by both pointers cannot actually be modified, otherwise such modification can give unpredictable result. See also this discussion:
http://www.cplusplus.com/forum/general/17155/[^].

—SA
 
Share this answer
 
Comments
RedDk 17-Feb-13 14:47pm    
Sorry SA!!!
Accidently hit the one-vote. Please reciprocate.
Sergey Alexandrovich Kryukov 17-Feb-13 16:49pm    
Not a problem. You can re-load the page and then vote again. The vote will be changed.
Thank you.
—SA
change the arguments of FormatEXTLOGPEN from EXTLOGPEN to EXTLOGPEN32

TreeDecode.h file:
static void FormatEXTLOGPEN(const EXTLOGPEN32 * lp, LPVOID p1, LPVOID p2);

TreeDecode.cpp file :
void TreeDecode::FormatEXTLOGPEN(const EXTLOGPEN32 * lp, LPVOID p1, LPVOID p2)
 
Share this answer
 
Thanks so much for your suggestions. What threw me off was that apparently Mr Newcomer originally built this application successfully with an earlier version of MS Studio. But I had the build issue when attemping with MS Studio 2010. As you can tell, I'm new to Visual Studio and new to C++ as well. I have primarily been using C because that's what my company's software is written in that I support. It has to be portable to run on Windows, Unix and z/OS platforms. I have written portable EMF driver code in C that will run on these platforms and allow a customer to create EMF files on any of them. Mr Newcomer's utility is great for debugging EMF file issues. That's why I use it.

The bottom line is I have to get better with using C++ and Visual Studio before even attempting to handle enhancements to this Visual Studio project. This is the beginning for me. Thanks for the feedback. I really appreciate it. I'll take this info and run with it.
 
Share this answer
 
Comments
SuperDre 28-Jul-14 6:14am    
well, the problem lies with this line:
FormatEXTLOGPEN(&((EMREXTCREATEPEN*)rec)->elp, p1, (LPVOID)lpen);
But how do you actually fixed it? (I'm very new to C++, but I need to recompile the project as the original exe requires the MFC71U.DLL which isn't available anymore..

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