|
File Viewer Creation
You can create a file viewer that interacts appropriately with Quick View by
following these steps:
- Define the file viewer object to use the IPersistFile and IFileViewer interfaces. The object must also implement a separate IUnknown interface that does not delegate calls in aggregation situations. In general,
a file viewer object creates or attaches to a window that displays a file's
contents.
- Implement the Load and GetCurFile member functions (as well as the IUnknown member functions) of the IPersistFile interface. The IsDirty member function can simply return ResultFromScode(S_FALSE) because a file viewer does not modify the file, and the Save and SaveCompleted member functions should simply return ResultFromScode(E_NOTIMPL). Load stores the filename, but delays opening the file until the later call to the IFileViewer::ShowInitialize member function. GetCurFile returns ResultFromScode(E_UNEXPECTED) if Load has not yet been called. Otherwise, it copies the pathname and returns the
NOERROR error code.
- Implement the IFileViewer::ShowInitialize and IFileViewer::Show member functions (as well as the IUnknown member functions of IFileViewer). ShowInitialize must perform all operations that are prone to failure such that if ShowInitialize succeeds, Show will never fail. The implementation of these two member functions is like an
implementation of an application's WinMain function, where ShowInitialize registers window classes (using the instance handle that the DLL receives in
its DllEntryPoint function, not the instance of Quick View), creates the necessary windows to
meet the UI guidelines, and loads the file as read-only with the path given in IPersistFile::Load. Then Show displays the contents of that file in the viewport window, shows the
top-level file viewer window, and enters a message loop. To enhance the appearance of
the UI, the file should be loaded and completely displayed in the viewport
window before the windows are made visible.
Show does not return until the user has closed the window; that is, Quick View
waits for Show to return before terminating. Quick View delegates the responsibility of the
message loop to the Show member function, so ShowInitialize and Show look and behave exactly like a WinMain function in any application (the code is just stored in a DLL).
Note that the path in the IPersistFile::Load member function may be a uniform naming convention (UNC) path. Functions such
as Win32 OpenFile and OLE StgOpenStorage automatically handle UNC paths. If you open a file any other way, you must be
sure to handle UNC paths properly.
- Define the class factory object with the IClassFactory interface and implement the interface completely to create a file viewer
object. The class factory must support aggregation and server locking, as required
by the IClassFactory interface.
- Implement the DllGetClassObject function to create an instance of the class factory mentioned in step 4 and
return a pointer to one of its interfaces, as required for any component object
DLL.
- Implement the DllCanUnloadNow function to return the appropriate code, depending on the number of file
viewer objects in service and the number of lock counts implemented by using the IClassFactory::LockServer member function, as required for any component object DLL.
- Include the Print To feature by using the IFileViewer::PrintTo member function. This step is optional. If this feature is not implemented, the member
function must return ResultFromScode(E_NOTIMPL).
- Finish the DLL implementation by using the DllEntryPoint function, as required for any Win32-based DLL.
In general, only the implementations of IPersistFile::Load and the IFileViewer member functions are specific to a file viewer. The other steps that deal
with creating an OLE component object are standard OLE mechanisms.
| Last news from Greatis Software |
 |
|
Nostalgia .Net |
|
.Net is powerful, but not all-powerful, so sometimes we need to use Win32 API for our .Net applications. It's simple enough with Platform Invoke if you have Win32 skill, but we do not always have time to dig the ancient documentation, declare the special types that are compatible with Win32, find the values of the Win32's constants and so on. Nostalgia .Net offers several simple-to-use classes, and components that will allow you to forget about the headache of Win32 and just use the power of Win32 in your application the same way as you use the native. Net classes. More » |
| Recommended software for developers |
 |
|
Ultimate Pack |
|
Component pack for Delphi and C++ Builder that contains runtime form designer, runtime object inspector, print suite and much more for the very special price. More » |
 |
|
Form Designer .Net |
|
Unique runtime form design solution that allows to edit any form in .Net WinForms application at runtime with full source codes for only 300 euro! More » |
 |
|
Print Suite .Net |
|
Print Suite .Net is a set of components for easy printing texts, images and grids from your WinForms applications. Full C# source codes are available More » |
 |
|
Gradient Controls .Net |
|
Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available More » |
 |
|
Greatis iGrid |
|
iGrid plots drawing grid right over your desktop, so you can use it everywhere, with any drawing application without any special plugins for different graphic editors. More » |
All the contacts and projectsDmitry Vasiliev (just.dmitry)
Related LinksSoftware for Visual Studio .NET developers Software for Delphi and C++ Builder developers Software for Visual Basic 6 developers Delphi Tips&Tricks MegaDetailed.NET More Online Helps Win32 Programmer's Reference Win32 Multimedia Programmer's Reference OLE Programmer's Reference Microsoft Windows Pen API Programmer's Reference Microsoft Windows Sockets 2 Reference Microsoft Windows Telephony API (TAPI) Programmer's Reference Unix Manual Pages
|