如前所述,您指出的示例项目不使用MFC,而是WTL,它是ATL的扩展,目前没有与Visual Studio一起提供。 因此,为了让他们编译你必须download WTL,安装并摆脱了一些弃用的东西。
但是,当然,接口也可以用在MFC应用程序中。 对于启动,下面是一个简单的例子:
class CMainDialog : public CDialog
{
// ...
CComPtr<ITaskbarList3> m_spTaskbarList;
};
BOOL CMainDialog::OnInitDialog()
{
CDialog::OnInitDialog();
// ...
HRESULT hr = ::CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER,
__uuidof(ITaskbarList3), reinterpret_cast<void**>(&m_spTaskbarList));
if(SUCCEDDED(hr))
{
hr = m_spTaskbarList->HrInit();
}
// ...
return TRUE;
}
....当然,不要忘记调用AfxOleInit在应用程序的类InitInstance中方法。
[已更新]
对不起,我之前的例子是错误的!根据文档,在调用任何ITaskbarList3方法之前,必须处理“TaskbarButtonCreated”注册的消息,以确保任务栏按钮已就位。
UINT WM_TASKBAR_BUTTON_CREATED = ::RegisterWindowMessage(_T("TaskbarButtonCreated"));
BEGIN_MESSAGE_MAP(CMainDialog, CDialogEx)
// ...
ON_REGISTERED_MESSAGE(WM_TASKBAR_BUTTON_CREATED, OnTaskbarButtonCreated)
END_MESSAGE_MAP()
LRESULT CMainDialog::OnTaskbarButtonCreated(WPARAM wParam, LPARAM lParam)
{
HRESULT hr = ::CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER,
IID_ITaskbarList3, reinterpret_cast<void**>(&m_spTaskbarList));
if (FAILED(hr))
{
// handle error
return 0;
}
hr = m_spTaskbarList->HrInit();
// ....
// ... other taskbar list stuff.
return 0;
}
参见本文:Windows 7: Adding toolbar buttons to taskbar button flyout。
看到这篇文章在MSDN上:https://msdn.microsoft.com/en-us/library/windows/desktop/dd378460(v=vs.85).aspx#progress –
什么的C++版本和你是什么用于GUI? –
可再发行组件包被称为'2015 Redistrbutable(x86)-14.0.24215' –