J***@adobeforums.com
2007-01-05 08:06:26 UTC
Since there is apparently no way to determine the currently selected pages in the Pages Navigation panel (see Leonard Rosenthol, "Determining currently selected page(s)?" #1, 3 Jan 2007 3:59 am </cgi-bin/webx?14@@.3bc2ba82/0>) I had to create my own Page Ranges dialog box. There also doesn't seem to be any explicit documentation on how to use MFC in a Acrobat 8 plug-in, so I'll explain what I did to implement this dialog using Visual Studio 2005.
The easiest way to begin is to use the Acrobat 8 Plug-in Wizard mentioned on page 98 of the Guide to SDK Samples. You should read Developing Plug-ins and Applications (in particular Chapter 3, "Creating Plug-in and PDF Library Applications") but for some mysterious reason, that guide doesn't mention the wizard???
The reason you should use the Wizard is that it has a checkbox for "Plug-in uses MFC"!
Unfortunately I had already started my plug-in by following the instructions in the Developing Plug-ins doc. That recommends that you start off by copying the BasicPlugin sample which doesn't include any MFC support. So I used the Wizard to generate sample code with MFC support enabled and disabled. I then diffed the files to see what was required and retrofitted my Visual Studio solution to match.
It turns out there is really very little difference between a MFC-enabled plug-in and a normal plug-in.
The wizard will create stdafx.cpp and stdafx.h which you normally use for precompiling headers, but it doesn't bother to actually turn on their use.
In any case you need these two files because anywhere you include the Acrobat plugin header file, you need to include stdafx.h before it:
#include "stdafx.h"
#ifndef MAC_PLATFORM
#include "PIHeaders.h"
#endif
If you don't the compiler will complain that you can't include windows.h in a MFC dll (and PIHeaders.h includes windows.h if it hasn't been already).
Then, in your project properties, "Configuration Properties | General | Use of MFC"
should be set to "Use MFC in a Shared DLL" rather than the BasicPlugin's "Use Standard Windows Libraries".
In the "C++ | Preprocessor" section add _AFXDLL to the list of Preprocessor definitions.
That's basically it as far as project setup goes and like I said, if you start your plug-in by using the Acrobat 8 Plug-in Wizard it'll do all this for you. Unfortunately the wizard only creates a Debug configuration and not both a Debug and Release configuration which is standard on Visual Studio built projects. (I built a standard MFC dll and took a look at its Release configuration settings to figure out how to correctly generate a Release version of my plug-in).
It should now be a snap to get an MFC dialog to display from an Acrobat 8 plug-in right? That's what I thought until I actually tried it.
(continued in part 2)
The easiest way to begin is to use the Acrobat 8 Plug-in Wizard mentioned on page 98 of the Guide to SDK Samples. You should read Developing Plug-ins and Applications (in particular Chapter 3, "Creating Plug-in and PDF Library Applications") but for some mysterious reason, that guide doesn't mention the wizard???
The reason you should use the Wizard is that it has a checkbox for "Plug-in uses MFC"!
Unfortunately I had already started my plug-in by following the instructions in the Developing Plug-ins doc. That recommends that you start off by copying the BasicPlugin sample which doesn't include any MFC support. So I used the Wizard to generate sample code with MFC support enabled and disabled. I then diffed the files to see what was required and retrofitted my Visual Studio solution to match.
It turns out there is really very little difference between a MFC-enabled plug-in and a normal plug-in.
The wizard will create stdafx.cpp and stdafx.h which you normally use for precompiling headers, but it doesn't bother to actually turn on their use.
In any case you need these two files because anywhere you include the Acrobat plugin header file, you need to include stdafx.h before it:
#include "stdafx.h"
#ifndef MAC_PLATFORM
#include "PIHeaders.h"
#endif
If you don't the compiler will complain that you can't include windows.h in a MFC dll (and PIHeaders.h includes windows.h if it hasn't been already).
Then, in your project properties, "Configuration Properties | General | Use of MFC"
should be set to "Use MFC in a Shared DLL" rather than the BasicPlugin's "Use Standard Windows Libraries".
In the "C++ | Preprocessor" section add _AFXDLL to the list of Preprocessor definitions.
That's basically it as far as project setup goes and like I said, if you start your plug-in by using the Acrobat 8 Plug-in Wizard it'll do all this for you. Unfortunately the wizard only creates a Debug configuration and not both a Debug and Release configuration which is standard on Visual Studio built projects. (I built a standard MFC dll and took a look at its Release configuration settings to figure out how to correctly generate a Release version of my plug-in).
It should now be a snap to get an MFC dialog to display from an Acrobat 8 plug-in right? That's what I thought until I actually tried it.
(continued in part 2)