Solved

How to change MS code in MS Studio C++

Posted on 2016-10-25
5
30 Views
Last Modified: 2016-10-26
This is part of a solution to another problem I posted. However, I'd like to separate it out it make it less confusing.

I need to change one line in a Microsoft routine called CRecentFileList::Add in a Microsoft file called filelist.cpp. that is part of the Microsoft Foundation Classes.

1) Can I copy over filelist.cpp into my program as a new file?  If so, how?

2) Or should I change filelist.cpp and recompile the MFC?
0
Comment
Question by:DickStone
  • 2
  • 2
5 Comments
 
LVL 40

Expert Comment

by:evilrix
Comment Utility
Why don't you just subclass the existing class and specialise it?
0
 
LVL 32

Expert Comment

by:sarabande
Comment Utility
1) Can I copy over filelist.cpp into my program as a new file?  If so, how?
no, the filelist module is either in the static mfc library or if you link against mfc dll, in the mfc dll. if you add your own filelist.cpp to your project, you would get duplicate symbols and errors.

Or should I change filelist.cpp and recompile the MFC?
you could, since mfc contains the sources. but you shouldn't since any next update or release might overwrite your file. furthermore it is complex and costly to do so.


Why don't you just subclass the existing class and specialise it?
the existing class crashes in the questioner's environment. specializing rarely would solve the issue. moreover, the mfc class is implemented by an Active-X Control (via COM) which  (usually) don't have virtual member functions for specializing.

I would suggest you to report the error to Microsoft. if it is a bug, they probably can tell you a workaround. if it is a known problem it might be solved already in a further release.

another way is to using your own RecentFileList class. you may implement it by using a private inifile or by storing the recent files in the registry.

Sara
0
 

Accepted Solution

by:
DickStone earned 0 total points
Comment Utility
Fixed the problem by adding a CoInitialize(NULL) in the app initialization. It comes from the program being set up in VC++ 6.
0
 
LVL 40

Expert Comment

by:evilrix
Comment Utility
>> which  (usually) don't have virtual member functions

This one does. Various members of the Add method are virtual.
https://msdn.microsoft.com/en-us/library/z4kdz7tz.aspx
1
 
LVL 32

Expert Comment

by:sarabande
Comment Utility
virtual void Add(
   LPCTSTR lpszPathName,
   LPCTSTR lpszAppID
);
good catch. that is the function DickStone had problems with.

there would remain the problem that currently the class object was created by the mfc framework, but it might be possible to switch off the option for the automatic recent file list and use a specialized recent file list to avoid the error.

Sara
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now