Simplify Persistent Object Creation

Visual C++ does some of the work for you when you create a control. Instead of manually adding methods to the class, you can add methods from the ClassView window. This not only adds the prototype to the .h file, but it gives you an empty method into which you can place your code.

Follow the same steps you followed to create an ATL project with a full control. From the ClassView window, add the Load(), Save(), InitNew(), and IsDirty() methods. (You can add GetClsID() and GetSizeMax() if you want, but for the second example I didn't anticipate using them.)

The rest is easy. Just add your code to Load() and Save(), and the control will persist the desired data.

The second sample object is named AtlPersistControl2. ...

Get COM+ Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.