MFC Container based application - mfc

I have a Doc-View architecture based project completely ready. But now i want to convert it in container based application to provide OLE support to existing project.
if anyone know how to convert, please reply as soon as possible. i just need a way without copy paste of existing code to new container based application- i tried - not worked even after settings change.

There is a good worked example of this here. Basically all your CDocument derived classes must be now be derived from COLEDocument, and you need some extra code in your WinApp.InitInstance.
If you post the code that you tried, you may get a more detailed response as to what is going wrong.

Related

Is it fine to change code in installed apps in django

I have been using an app called django-easy-friends in my application.
Now problem i want to make some changes in the app installed. I want to make entries in a different table each time a new friend is added.
Now my question is, is it wise to change the code in installed apps? If not how else to customise the apps to be installed?
I don't like to modify code in third party libraries. If you find a bug, you rather fork the library, fix it, make a pull request and update it into your INSTALLED_APPS.
If you want to do some modifications to get different behavior, I think is wiser to subclass the class you want to modify, encapsulate it, monkey patch it, or whatever object oriented methodology you find suitable for the modification you want to make.
The problems with modifying code in third party libraries come to light when you want to update the third party library. You'll get all sort of errors when you do it. Because your changes would've pass unknown to the library makers and if for some reason you forget what the changes were, your app will become a real mess.
IMHO, you should not modify a third party library. Instead, proceed as recommended above, report a bug, subclass their classes, etc, but don't modify it!
Hope this helps!
I think you should be fine, as long as you stay away from editing your models, all you are going to do is change 'the way your app works'. If you do edit your models you may have to remove the database and re-sync it.

Problems overriding IAccessible::get_accName in MFC application

I'm currently working on a legacy MFC application undergoing a major upgrade. One of the things we're changing is how we test this. We want to create GUI automation tests for the application, and to that end, we're using UI spy to inspect the visual elements, pull out automation names and IDs and help us write our tests. However, unfortunately, a lot of elements (ie tree items, text boxes) don't have automation names associated with them, and we'd like to add them. From what I've been able to find by googling around, overriding CWnd::get_accName should allow us to associate accessibility API names with the elements, but when I override it, nothing changes and I can't see the newly assigned name. Have I missed something ? Can somebody please point me in the right direction for adding accessibility information to an MFC application ?
Ensure you are calling EnableActiveAccessibility() in the CWnd-derived class constructor.

When is it OK to inject the injector?

If you take a look at the library I've been working on for dependency injection in C++, I recently added an example that mimics something I created for a real project: the ability to inject application configuration directly.
This all works fine as the constructor just asks for a ConfigItem<ConfigTag> type and that is magically delivered.
A problem occurs when I need to access all of them at the same time (say for a configuration dialog).
The stupid solution I came up with was to generate, using the preprocessor, a class that gets all the configuration items in the constructor as shown here.
This problem would be "nicely" solved if I could inject the injector as I would then only have to generate the code to collect all the ConfigItem instances as shown here.
Note that all the ConfigItems are within a singleton scope.
Hope this question makes sense: how would you do this?
Sounds like you have re-invented the Service Locator Pattern

To modify start-up behavior of an MFC app

This is my first substantial MFC application.
My out-of-the-wizard MFC app wants to open a blank, new file of the type I specified for my app, when it starts, but that's not meaningful for my application. I want my app to open some connections to some remote sites and get data from them.
Where should I consider interrupting or overriding MFC's default behavior? I could subclass CWinApp::ProcessShellCommand(). I could modify the CCommandLineInfo object it works on. I could excise the whole command line processing and just call my go-get-the-data functions. I probably should just altogether excise the whole document-as-a-file related processing. I'm not opening or saving any files, except debug files or logs that are outside of the UI's concern. The only saving or collecting of local information is via a database, to which and from which I handle the serialization myself, so no CArchive, either.
I've got all this code but it's hanging in front of me disjointed and disintegrated. I'm too new to this and there's too many alternatives. Some simple guidance for a simple beginner is what I'm asking for.
So, if you'll say, sure, lop off the document-as-file handling, tell me, please, where I need to go to do that bit of surgery, I can see it's not just one object that'd be affected. And so forth. Thanks.
You might consider generating a new application, but when you do, tell it that you want a database application without file handling. Even if you don't use its database capability, it'll produce an application whose basic layout is set up roughly for what you're trying to do, so you'll basically just substitute your database interface for what it provides, but won't get involved with trying to rip out file handling and such that's apparently irrelevant for your program.
I found an answer with respect to modifying default file opening. While I made the database app Coffin suggested, I saw the phrase "storing database objects in views" and I rather aimlessly searched MSDN with that. If I was going to try the database app approach and do my own serialization, I had to learn about this.
I thus found an MSDN page concerning handling the file menu in database apps, which discusses how to alter and even disable the OnFileOpen command. It's applicable to OnFile New and it is the approach I was hoping for.

Converting registry access to db calls from MFC Feature Pack

We may start converting an old VS2003 MFC project to use the fancy new features provided by the MFC Feature Pack and VS2008. Several of the new UI controls would be very nice except for one thing - they automatically save their information to the registry. I don't have a problem with the registry, but for the multiple environments the users use out program from, it's much easier to save user data to the database.
So, I'm hoping that there is one main "access the registry" function that could be overloaded to point the database. But brief investigation hasn't turned up anything. Has anyone else had any success doing something similar?
It seems like it should be possible to do what you're suggesting, according to the information on this page in MSDN. I haven't tried this myself, so I don't know how difficult it will be in practice.
According to the documentation, you should create a class that inherits CSettingsStore to read and write the settings, and call CSettingsStoreSP::SetRuntimeClass so that the framework uses your class instead of the default.
The MFC feature pack uses code supplied by BCGSoft and they added this feature (so you can save state to an XML file, database, etc.) way back in 2001. I don't have the feature pack on this PC but try looking for a class called something like CMFCRegistrySP.
I will check myself tomorrow.
Does the StateCollection sample do this?
http://msdn.microsoft.com/en-us/library/bb983406.aspx