IPublishingWizard 接口 (shobjidl.h)

公开使用联机打印向导、Web 发布向导和添加网络位置向导的方法。 在 Windows Vista 中, IPublishingWizard 不再支持 Web 发布向导或联机打印向导。

继承

IPublishingWizard 接口继承自 IWizardExtensionIPublishingWizard 也有以下类型的成员:

方法

IPublishingWizard 接口具有这些方法。

 
IPublishingWizard::GetTransferManifest

获取由发布向导(例如联机打印向导或添加网络位置向导)执行的文件传输操作的传输清单。
IPublishingWizard::Initialize

使用要传输的文件、要使用的设置以及要创建的向导类型初始化发布向导对象。

注解

联机打印向导是用于在线订购照片打印的向导。 Windows Vista 不再支持使用 IPublishingWizard 来处理联机打印向导。

“添加网络位置向导”允许用户在 Windows XP) 中的“我的网络Places (”或 Windows Vista) 中的“计算机 (”中创建网络资源的快捷方式。

Windows Shell 提供实现 IPublishingWizardIWizardExtension 的发布向导对象IPublishingWizard 的方法用于初始化向导的类型、设置向导的某些属性以及检索传输清单。 IWizardExtension 的方法用于检索构成所选向导正文的扩展页。 若要实例化 发布向导对象,请调用 CoCreateInstance 并使用 CLSID) CLSID_PublishingWizard 和 IID_IPublishingWizard 作为 REFIID 的类标识符 (。

IPublishingWizard *pPublish = NULL;

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

实例化 发布向导对象 后,调用 IPublishingWizard::Initialize 以初始化 发布向导对象

注意 以下示例不适用于 Windows Vista,因为 IPublishingWizard 方法不再支持 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.

请注意, IPublishingWizard::Initialize 实际上并不显示向导。 若要显示联机打印向导,必须创建 PROPSHEETHEADER 结构,然后修改其 phpage 成员以包含 IWizardExtension::AddPages 返回的 PROPSHEETPAGE 句柄数组。 IWizardExtension::AddPages 由实现 IPublishingWizard 的同一发布向导对象实现。

如果显示联机打印向导,则应在包含扩展页的 PROPSHEETHEADER 结构的 dwFlags 成员中设置PSH_NOMARGIN标志。

除了从 IWizardExtension::AddPages 检索的扩展页外, phpage 数组还应包含应用程序提供的起始页、取消页和完成页。 当用户退出或取消扩展时,或者当扩展完成显示其页面时,扩展会通知向导,它必须从扩展页堆栈中导航到其中一个应用程序提供的页面。 应用程序必须提供处理此通信的 IWizardSite 的实现。 必须将 IPublishingWizard 对象的站点设置为 IWizardSite 实现。 IUnknown_SetSite 函数可用于设置站点。 应用程序使用 IPublishingWizard::Initialize 指定向导设置后,正确填充 PROPSHEETHEADER 结构的 phpage 成员,并将站点设置为 IWizardSite 的实现后,可以通过调用 PropertySheet 函数来显示向导。

/* 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);
}

要求

要求
最低受支持的客户端 Windows XP、Windows Vista [仅限桌面应用]
最低受支持的服务器 Windows Server 2008 [仅限桌面应用]
目标平台 Windows
标头 shobjidl.h

另请参阅

IWizardExtension

IWizardExtension::AddPages

IWizardSite

PROPSHEETHEADER

发布向导对象