diff --git a/include/wx/taskbarbutton.h b/include/wx/taskbarbutton.h index 8b88f438a8..a75aeb76a5 100644 --- a/include/wx/taskbarbutton.h +++ b/include/wx/taskbarbutton.h @@ -130,16 +130,25 @@ private: wxDECLARE_NO_COPY_CLASS(wxTaskBarButton); }; +enum WXDLLIMPEXP_CORE wxJumpListItemType { + wxJUMP_LIST_SEPARATOR, + wxJUMP_LIST_TASK, + wxJUMP_LIST_DESTIONATION +}; + class WXDLLIMPEXP_CORE wxJumpListItem { public: - wxJumpListItem(const wxString& title = wxEmptyString, + wxJumpListItem(wxJumpListItemType type, + const wxString& title = wxEmptyString, const wxString& filePath = wxEmptyString, const wxString& arguments = wxEmptyString, const wxString& tooltip = wxEmptyString, const wxString& iconPath = wxEmptyString, int iconIndex = 0); + wxJumpListItemType GetType() const; + void SetType(wxJumpListItemType type); const wxString& GetTitle() const; void SetTitle(const wxString& title); const wxString& GetFilePath() const; @@ -154,6 +163,7 @@ public: void SetIconIndex(int iconIndex); private: + wxJumpListItemType m_type; wxString m_title; wxString m_filePath; wxString m_arguments; diff --git a/samples/taskbarbutton/taskbarbutton.cpp b/samples/taskbarbutton/taskbarbutton.cpp index 123f5c2c80..f703ac6cb2 100644 --- a/samples/taskbarbutton/taskbarbutton.cpp +++ b/samples/taskbarbutton/taskbarbutton.cpp @@ -141,13 +141,23 @@ bool MyApp::OnInit() return false; wxJumpList jump; wxJumpListItems tasks; - wxJumpListItem item(wxT("Task 1"), - wxStandardPaths::Get().GetExecutablePath(), - wxEmptyString, - wxT("Test Task"), - wxStandardPaths::Get().GetExecutablePath(), - 0); - tasks.push_back(item); + wxJumpListItem item1(wxJUMP_LIST_TASK, + wxT("Task 1"), + wxStandardPaths::Get().GetExecutablePath(), + wxEmptyString, + wxT("Test Task"), + wxStandardPaths::Get().GetExecutablePath(), + 0); + wxJumpListItem item2(wxJUMP_LIST_TASK, + wxT("Task 2"), + wxStandardPaths::Get().GetExecutablePath(), + wxEmptyString, + wxT("Test Task"), + wxStandardPaths::Get().GetExecutablePath(), + 0); + tasks.push_back(item1); + tasks.push_back(wxJumpListItem(wxJUMP_LIST_SEPARATOR)); + tasks.push_back(item2); jump.SetTasks(tasks); MyFrame *frame = new MyFrame("wxTaskBarButton App"); diff --git a/src/msw/taskbarbutton.cpp b/src/msw/taskbarbutton.cpp index a5bb94007b..a17aa1f478 100644 --- a/src/msw/taskbarbutton.cpp +++ b/src/msw/taskbarbutton.cpp @@ -122,7 +122,6 @@ public: virtual HRESULT wxSTDCALL SetThumbnailClip(HWND, RECT *) = 0; }; - class IShellLinkA : public IUnknown { public: @@ -214,7 +213,7 @@ THUMBBUTTONFLAGS GetNativeThumbButtonFlags(const wxThumbBarButton& button) return static_cast(flags); } -IShellLink* CreateShellLink(const wxJumpListItem& item) +bool AddShellLink(IObjectCollection *collection, const wxJumpListItem& item) { IShellLink* shellLink = NULL; IPropertyStore* propertyStore = NULL; @@ -230,39 +229,62 @@ IShellLink* CreateShellLink(const wxJumpListItem& item) if ( FAILED(hr) ) { wxLogApiError("CoCreateInstance(wxCLSID_ShellLink)", hr); - return shellLink; + return false; } - if ( !item.GetFilePath().IsEmpty() ) - shellLink->SetPath(item.GetFilePath().wc_str()); - if ( !item.GetArguments().IsEmpty() ) - shellLink->SetArguments(item.GetArguments().wc_str()); - if ( !item.GetIconPath().IsEmpty() ) + if ( item.GetType() == wxJUMP_LIST_TASK ) { - shellLink->SetIconLocation(item.GetIconPath().wc_str(), - item.GetIconIndex()); + if ( !item.GetFilePath().IsEmpty() ) + shellLink->SetPath(item.GetFilePath().wc_str()); + if ( !item.GetArguments().IsEmpty() ) + shellLink->SetArguments(item.GetArguments().wc_str()); + if ( !item.GetIconPath().IsEmpty() ) + { + shellLink->SetIconLocation(item.GetIconPath().wc_str(), + item.GetIconIndex()); + } + if ( !item.GetTooltip().IsEmpty() ) + shellLink->SetDescription(item.GetTooltip().wc_str()); } - if ( !item.GetTooltip().IsEmpty() ) - shellLink->SetDescription(item.GetTooltip().wc_str()); hr = shellLink->QueryInterface(IID_IPropertyStore, - reinterpret_cast(&(propertyStore))); - if ( SUCCEEDED(hr )) + reinterpret_cast(&(propertyStore))); + if ( FAILED(hr) ) + { + wxLogApiError("IShellLink(QueryInterface)", hr); + shellLink->Release(); + return false; + } + + PROPVARIANT pv; + if ( item.GetType() == wxJUMP_LIST_TASK ) { - PROPVARIANT pv; hr = InitPropVariantFromString(item.GetTitle().wc_str(), &pv); if ( SUCCEEDED(hr) ) { hr = propertyStore->SetValue(PKEY_Title, pv); } - - //Save the changes we made to the property store - propertyStore->Commit(); - propertyStore->Release(); - PropVariantClear(&pv); + } + else if ( item.GetType() == wxJUMP_LIST_SEPARATOR ) + { + hr = InitPropVariantFromBoolean(TRUE, &pv); + if ( SUCCEEDED(hr) ) + { + hr = propertyStore->SetValue(PKEY_AppUserModel_IsDestListSeparator, + pv); + } } - return shellLink; + // Save the changes we made to the property store. + propertyStore->Commit(); + propertyStore->Release(); + PropVariantClear(&pv); + + // Add this IShellLink object to the given collection. + hr = collection->AddObject(shellLink); + + shellLink->Release(); + return SUCCEEDED(hr); } } // namespace @@ -639,13 +661,15 @@ void wxAppProgressIndicator::Init() } } -wxJumpListItem::wxJumpListItem(const wxString& title, +wxJumpListItem::wxJumpListItem(wxJumpListItemType type, + const wxString& title, const wxString& filePath, const wxString& arguments, const wxString& tooltip, const wxString& iconPath, int iconIndex) - : m_title(title), + : m_type(type), + m_title(title), m_filePath(filePath), m_arguments(arguments), m_tooltip(tooltip), @@ -654,6 +678,17 @@ wxJumpListItem::wxJumpListItem(const wxString& title, { } + +wxJumpListItemType wxJumpListItem::GetType() const +{ + return m_type; +} + +void wxJumpListItem::SetType(wxJumpListItemType type) +{ + m_type = type; +} + const wxString& wxJumpListItem::GetTitle() const { return m_title; @@ -793,7 +828,7 @@ void wxJumpList::AddTasksToDestinationList() iter != m_tasks.end(); ++iter ) { - collection->AddObject(CreateShellLink(*iter)); + AddShellLink(collection, *iter); } m_destinationList->AddUserTasks(objectArray);