Solved

How to change MS code in MS Studio C++

Posted on 2016-10-25
5
50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

930 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

12 Experts available now in Live!

Get 1:1 Help Now