Solved

How to change MS code in MS Studio C++

Posted on 2016-10-25
5
76 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 34

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 34

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

687 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