Solved

ATL Control and Persistence

Posted on 1999-01-20
5
245 Views
Last Modified: 2013-11-25
I created a control using the ATL wizards in VC++ 6.  I added a 'Full Control' into the ATL project (derived from a Combo Box) and a 'Property Page' object.

I added several check boxes onto the property page, then tied them to the control using PROP_ENTRY and the IDL ID.  When I use my new control in Test Container, the property page works fine.  It remembers it's settings and implements the changes correctly.

However, when I try to insert my control into a test MFC applet, the property page does not work as expected.  When I bring up the properties, the page is initialised correctly.  Setting options and closing the properties dialog, then bringing it up again seems to remember the settings I chose, but the moment I save the resource, the changes are lost.

Do I have to implement persistence for my property page/control (Save/Load/InitNew methods) and if so, how do I go about doing this - MSDN seems very contradictory in this area.

Thanks,

Mark.
0
Comment
Question by:pswann
5 Comments
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1328006
Persistence is a weird subject because there have been many different versions and different attempts at it. Basically, the idea is that the container knows where to save things and asks each of the controls to save themselves. But the main problem is that there are three different methods of persistence: IPersistStorage, IPersistStreamInit, and IPersistPropertyBag. It is up to the container to decide which of these interfaces to support. ATL helps a lot here, but not all of it.

ATL only supports integer properties for persistence. If you have any other data types (objects or strings, or anything else), you will need to write the code yourself.

I would recommend you go to http://www.wrox.com and download the code for Beginning ATL COM Programming and take a look at the code for chapter 8. Another resource is at the same web site, but download Professional ATL COM Programming and look at the code for Chapter 10. Both of these books are excellent for ATL programming.
0
 
LVL 23

Expert Comment

by:naveenkohli
ID: 1328007
There is an article on www.codeguru.com under ATL & COM. Its titled "ActiveX Control Tutuorial". It explains the persistence and has implemented all possible persistence types for an control. It should give you an a idea,
0
 

Author Comment

by:pswann
ID: 1328008
We have had a look at the web sites indicated above but they did not provide any information as to why our information is not be serialised correctly within the resource.

The properties  we are attempting so save are all integer properties. (we have 5 separate checkboxes on a property page). We are using the Prop_Entry() macro and we believe this should be sufficient to serialise these properties ?
0
 
LVL 3

Accepted Solution

by:
shaig earned 300 total points
ID: 1328009
Adding entries to the property map isn't enough.
You should inherit from the proper templates and add the interfaces to your object.

All interfaces thui mentioned have ...Impl templates to inherit from, dig into this direction.

0
 

Author Comment

by:pswann
ID: 1328010
Thuis answer was probably better but thanks for the advice
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sumNumber challenge 16 122
has22 challenge 11 96
Poor Man's .NET Framework Certification 2 59
Microsoft C++ code failing in executable that worked 9 100
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

809 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