如何自定义数据 Link 属性对话框中的连接选项卡?

How to customize the Connection tab in the Data Link Properties dialog?

我正在开发一个 OLEDB 提供程序,它现在利用 IDBPromptInitialize::PromptDataSource() 提供的 "default" 连接对话框,看起来像 this。当我将我的提供商与某些客户端工具(如 MS Excel 或 .udl 文件)一起使用时,会出现相同的 UI。我现在打算创建自己的 UI.

当在 Provider 选项卡中选择不同的 OLEDB Provider 时,我注意到其中一些的 Connection 选项卡看起来很不一样,例如SQL Server Native Client 11.0.

所以定制它在技术上似乎是可行的。我的问题是:如何?

注意:我知道我可以将自己的 UI 放在一起,并且可以随时弹出。但这不会神奇地集成到数据 Link 属性对话框的连接选项卡中,对吗?

谢谢!


编辑

显然,我接受答案太快了。我按照描述执行了所有步骤。当我在创建 属性 sheet 的测试应用程序中使用我的提供程序时,一切正常 [漂亮][3]。我的测试应用程序在我的提供商上调用 ISpecifyPropertyPages::GetPages,并将结果传递给 OleCreatePropertyFrame,如答案中所述。

但是,当我将它与数据 Link 对话框一起使用时,只要我 select 我的提供商并单击“下一步”按钮或其中一个选项卡,这些选项卡就会消失。只有提供商选项卡保留。 调试它我可以看到 GetPages 被成功调用,但是只有我的 ConnectionTab 的构造函数被调用(没有任何错误)并且选项卡立即消失(没有崩溃!)。没有调用 IPropertyPage 方法或任何其他方法。 知道可能是什么问题吗?


编辑 - 已解决

好的,我知道了。在我的 AdvancedTab class 中,我缺少 COM 映射中的 COM_INTERFACE_ENTRY(IPersistPropertyBag)。我过于关注“连接”选项卡,因为我想让它先工作。

如果有人感兴趣: 将 #define _ATL_DEBUG_QI 放在 #include <atlcom.h> 之前让我发现 QueryInterface 调用失败 IPersistPropertyBag.

此处描述:Interfaces Implemented by the Provider

实现 IIDBInitialize/IDBProperties 的 OLEDB 提供者对象也必须实现 IServiceProvider.

系统将使用 OLEDB_SVC_DSLPropertyPages(来自 MSDAGUID.H)作为服务 guid 和 ISpecifyPropertyPages 作为接口 ID 调用此 IServiceProvider 实现。

ISpecifyPropertyPages::GetPages Fills a counted array of GUID values, where each GUID specifies the CLSID of each property page that can be displayed in the property sheet for this object. GetPages is called by the Data Link core component to get an array of exactly two CLSIDs that represent the extensible property pages: the first to replace the Connection tab, and the second to replace the Advanced tab. These pages must be registered properly so that they can be cocreated by the Data Link core component in-process.

这些 属性 页是标准的 Windows property pages