Επεξεργασία

Κοινή χρήση μέσω


IPublishingWizard interface (shobjidl.h)

Exposes methods for working with the Online Print Wizard, the Web Publishing Wizard, and the Add Network Place Wizard. In Windows Vista, IPublishingWizard no longer supports the Web Publishing Wizard or Online Print Wizard.

Inheritance

The IPublishingWizard interface inherits from IWizardExtension. IPublishingWizard also has these types of members:

Methods

The IPublishingWizard interface has these methods.

 
IPublishingWizard::GetTransferManifest

Gets a transfer manifest for a file transfer operation performed by a publishing wizard, such as the Online Print Wizard or the Add Network Place Wizard.
IPublishingWizard::Initialize

Initializes the Publishing Wizard object with the files to transfer, the settings to use, and the type of wizard to create.

Remarks

The Online Print Wizard is a wizard for ordering prints of photos online. The use of IPublishingWizard to work with the Online Print Wizard is no longer supported in Windows Vista.

The Add Network Place Wizard allows the user to create a shortcut to network resources in My Network Places (in Windows XP) or Computer (in Windows Vista).

The Windows Shell supplies a Publishing Wizard object that implements IPublishingWizard and IWizardExtension. The methods of IPublishingWizard are used to initialize the type of the wizard, set certain attributes of the wizard, and retrieve a transfer manifest. The methods of IWizardExtension are used to retrieve the extension pages that make up the body of the selected wizard. To instantiate the Publishing Wizard object, call CoCreateInstance and use the class identifier (CLSID) CLSID_PublishingWizard and IID_IPublishingWizard as the REFIID.

IPublishingWizard *pPublish = NULL;

HRESULT hr = CoCreateInstance(CLSID_PublishingWizard, 
                              NULL,
                              CLSCTX_INPROC_SERVER, 
                              IID_IPublishingWizard, 
                              (LPVOID*)&pPublish);

Once the Publishing Wizard object has been instantiated, call IPublishingWizard::Initialize to initialize the Publishing Wizard object.

Note  The examples below will not work on Windows Vista since the IPublishingWizard methods no longer support the Online Printing Wizard in Windows Vista.
 
// Initializing the Online Print Wizard
                    
hr = pPublish->Initialize(pDataObject,
                          SHPWHF_NOFILESELECTOR,
                          L"InternetPhotoPrinting");
                          
// pDataObject: A data object that represents files or folders to transfer.
// SHPWHF_NOFILESELECTOR: This flag must be set.
// L"InternetPhotoPrinting": Display the Online Print Wizard.

Note that IPublishingWizard::Initialize does not actually display the wizard. In order to display the Online Print Wizard, you must create a PROPSHEETHEADER structure and then modify its phpage member to include the array of PROPSHEETPAGE handles returned by IWizardExtension::AddPages. IWizardExtension::AddPages is implemented by the same Publishing Wizard object that implements IPublishingWizard.

If displaying the Online Print Wizard, the PSH_NOMARGIN flag should be set in the dwFlags member of the PROPSHEETHEADER structure that contains the extension pages.

In addition to the extension pages retrieved from IWizardExtension::AddPages, the phpage array should include a start page, a cancel page, and a finish page, provided by your application. When the user backs out of or cancels the extension, or when the extension finishes displaying its pages, the extension then communicates to the wizard that it must navigate out of the stack of extension pages to one of these application-provided pages. Your application must supply an implementation of IWizardSite that handles this communication. The IPublishingWizard object's site must be set to your IWizardSite implementation. The IUnknown_SetSite function can be used to set the site. Once your application has specified the wizard settings using IPublishingWizard::Initialize, properly populated the phpage member of a PROPSHEETHEADER structure, and set the site to an implementation of IWizardSite, the wizard may be displayed by calling the PropertySheet function.

/* This is example code demonstrating how to populate a PROPSHEETHEADER
structure and use it to display the Online Print Wizard.
This sample assumes that the PublishingWizard object has already
been instantiated and initialized elsewhere in the application. */

// Define the number of wizard pages that we expect to get from 
// the Publishing Wizard object. 
// The Online Print Wizard provides 6 predefined pages in Windows Vista,
// but provided 9 in Windows XP. 
#if NTDDI_VERSION >= NTDDI_VISTA
#define NUMPAGES 6  
#else
#define NUMPAGES 9
#endif

// Number of wizard pages supplied by the application in addition to 
// the predefined pages supplied by the Online Print Wizard. 
#define NUMNONEXTENSIONPAGES 3

// Array to hold the property sheets to display in the wizard,
// including both those returned by IPublishingWizard::AddPages()
// and those application-defined pages returned by IWizardSite methods.
HPROPSHEETPAGE hPropSheets[NUMPAGES + NUMNONEXTENSIONPAGES];

// Handles to the application-defined property sheets.
// This example assumes that they are initialized elsewhere in the application.
HPROPSHEETPAGE hPropSheetFinishPage = CreateFinishPage;
HPROPSHEETPAGE hPropSheetStartPage = CreateStartPage;
HPROPSHEETPAGE hPropSheetCanceledPage = CreateCanceledPage;

// Number of property sheets returned by IPublishingWizard::AddPages().
UINT uCount = 0;
INT_PTR retval = 0; // return value from PropertySheet
HRESULT hr;

// Property sheet header structure whose phpage member will receive
// the array of wizard pages retrieved from AddPages.
PROPSHEETHEADER psh;
psh.dwSize = sizeof(PROPSHEETHEADER);

// Set the PublishingWizard object's site to an IWizardSite implementation
// defined by your application.  
hr = IUnknown_SetSite(pIPublish, (IUnknown *)pWizSite);

// Fill the hPropSheets array with the pages of the wizard.
if SUCCEEDED(hr)
{
    hr = pIPublish->AddPages(&hPropSheets[0], NUMPAGES, &uCount);
}        

if SUCCEEDED(hr)
{
    // Define start, finish, and canceled pages elsewhere in your application.
    // Here, these pages are added after the extension pages.
    hPropSheets[uCount] = hPropSheetFinishPage;
    hPropSheets[uCount + 1] = hPropSheetCanceledPage;
    hPropSheets[uCount + 2] = hPropSheetStartPage;

    // Assign the array of property sheets.
    psh.phpage = hPropSheets;

    // Number of extension pages from AddPages + # of your own pages.
    psh.nPages = uCount + NUMNONEXTENSIONPAGES; 

    // The index into phpage where the first page to display is located.
    psh.nStartPage = 0;  

    // PSH_NOMARGIN must be specified for the Online Print Wizard.
    psh.dwFlags =  PSH_AEROWIZARD | PSH_WIZARD | PSH_NOMARGIN;
    psh.hwndParent = NULL;
    psh.hInstance = NULL;

    // Display the wizard.
    PropertySheet(&psh);
}

Requirements

Requirement Value
Minimum supported client Windows XP, Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header shobjidl.h

See also

IWizardExtension

IWizardExtension::AddPages

IWizardSite

PROPSHEETHEADER

Publishing Wizard object