Solved

How to change MS code in MS Studio C++

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Convert GUI app into console app for Win32 Env 5 109
c++ syntax question 9 52
PL SQL Developer 7 52
"Video DataSource is Offline or not responding"  - why? 1 71
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…
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 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 goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

856 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