Solved

How to change MS code in MS Studio C++

Posted on 2016-10-25
5
57 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
ID: 41858708
Why don't you just subclass the existing class and specialise it?
0
 
LVL 33

Expert Comment

by:sarabande
ID: 41859110
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
ID: 41859133
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
ID: 41859498
>> 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 33

Expert Comment

by:sarabande
ID: 41859892
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

770 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