void WinSevenTaskbar::createInterface(void) { if(!m_ptbl) { ITaskbarList3 *ptbl = NULL; HRESULT hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&ptbl)); if (SUCCEEDED(hr)) { HRESULT hr2 = ptbl->HrInit(); if(SUCCEEDED(hr2)) { m_ptbl = ptbl; /*qDebug("ITaskbarList3::HrInit() succeeded.");*/ } else { ptbl->Release(); qWarning("ITaskbarList3::HrInit() has failed."); } } else { qWarning("ITaskbarList3 could not be created."); } } }
void UnregisterTab(HWND tab) { ITaskbarList3 *taskbar; if(!(tab)) return; if(S_OK != CoCreateInstance(CLSID_TaskbarList, 0, CLSCTX_INPROC_SERVER, IID_ITaskbarList3, (void**)&taskbar)) return; taskbar->HrInit(); taskbar->UnregisterTab(tab); taskbar->Release(); }
void MainWindow::radioSetMuted(bool muted) { radioMuted = muted; if (currentStream) BASS_ChannelSetAttribute(currentStream, BASS_ATTRIB_VOL, radioGetVolume()); if (OSUtil::IsVistaOrLater()) { SendMessage(volumePbar, PBM_SETSTATE, muted ? (isColorblindModeEnabled ? PBST_PAUSED : PBST_ERROR) : PBST_NORMAL, (LPARAM)0); } else if (IsAppThemed() == FALSE) { SendMessage(volumePbar, PBM_SETBARCOLOR, (WPARAM)0, (LPARAM)(muted ? RGB(255, 0, 0) : CLR_DEFAULT)); } ShowWindow(volumePbar, SW_SHOW); if (muted) KillTimer(window, hideVolBarTimerId); else SetTimer(window, hideVolBarTimerId, 1000, nullptr); updateStatusLabel(); if (OSUtil::IsWin7OrLater()) { ITaskbarList3 *taskbarList; if (SUCCEEDED(CoCreateInstance(CLSID_TaskbarList, nullptr, CLSCTX_INPROC_SERVER, __uuidof(taskbarList), reinterpret_cast<void**>(&taskbarList)))) { HICON icon = LoadIcon(instance, MAKEINTRESOURCE(muted ? IDI_ICON_SOUND : IDI_ICON_MUTE)); THUMBBUTTON thumbButtons[1]; thumbButtons[0].dwMask = THB_ICON; thumbButtons[0].iId = thumbBarMuteBtnId; thumbButtons[0].hIcon = icon; taskbarList->ThumbBarUpdateButtons(window, 1, thumbButtons); DeleteObject((HGDIOBJ)icon); taskbarList->SetProgressValue(window, muted ? 100UL : 0UL, 100UL); taskbarList->SetProgressState(window, muted ? TBPF_ERROR : TBPF_NOPROGRESS); taskbarList->Release(); } } }
void SetTabActive(HWND tab, HWND owner) { ITaskbarList3 *taskbar; if(!owner) return; if(S_OK != CoCreateInstance(CLSID_TaskbarList, 0, CLSCTX_INPROC_SERVER, IID_ITaskbarList3, (void**)&taskbar)) return; taskbar->HrInit(); taskbar->SetTabActive(tab, owner, 0); taskbar->Release(); }
void SetTabOrder(HWND tab, HWND insertBefore) { ITaskbarList3 *taskbar; if(!tab) return; if(S_OK != CoCreateInstance(CLSID_TaskbarList, 0, CLSCTX_INPROC_SERVER, IID_ITaskbarList3, (void**)&taskbar)) return; taskbar->HrInit(); taskbar->SetTabOrder(tab, insertBefore); taskbar->Release(); }
TaskBarIface() : m_taskbarInterface(NULL) { HRESULT hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_ITaskbarList3, reinterpret_cast<void**> (&(m_taskbarInterface))); if (SUCCEEDED(hr)) { hr = m_taskbarInterface->HrInit(); if (FAILED(hr)) { m_taskbarInterface->Release(); m_taskbarInterface = NULL; } } }
void SetProgressState(HWND hWnd, ProgressStates state) { TBPFLAG flags; ITaskbarList3 *taskbar; if(S_OK != CoCreateInstance(CLSID_TaskbarList, 0, CLSCTX_INPROC_SERVER, IID_ITaskbarList3, (void**)&taskbar)) return; taskbar->HrInit(); switch (state) { default: case PS_None : flags = TBPF_NOPROGRESS; break; case PS_Normal : flags = TBPF_NORMAL; break; case PS_Paused : flags = TBPF_PAUSED; break; case PS_Error : flags = TBPF_ERROR; break; case PS_Indeterminate : flags = TBPF_INDETERMINATE; break; } taskbar->SetProgressState(hWnd, flags); taskbar->Release(); }
~TaskBarIface() { if (m_taskbarInterface) m_taskbarInterface->Release(); }
void SetUUIDOverlayIcon( HWND hWnd ) { if (CRegStdDWORD(_T("Software\\TortoiseGit\\GroupTaskbarIconsPerRepo"), 3)) { if (CRegStdDWORD(_T("Software\\TortoiseGit\\GroupTaskbarIconsPerRepoOverlay"), TRUE)) { std::wstring uuid; std::wstring sicon; bool bRemoveicon = false; #ifdef _MFC_VER uuid = g_sGroupingUUID; sicon = g_sGroupingIcon; bRemoveicon = g_bGroupingRemoveIcon; #else CCmdLineParser parser(GetCommandLine()); if (parser.HasVal(L"groupuuid")) uuid = parser.GetVal(L"groupuuid"); #endif if (!uuid.empty()) { ITaskbarList3 * pTaskbarInterface = NULL; HRESULT hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_ITaskbarList3, reinterpret_cast<void**> (&(pTaskbarInterface))); if (SUCCEEDED(hr)) { int foundUUIDIndex = 0; do { wchar_t buf[MAX_PATH] = {0}; swprintf_s(buf, _countof(buf), L"%s%d", L"Software\\TortoiseGit\\LastUsedUUIDsForGrouping\\", foundUUIDIndex); CRegStdString r = CRegStdString(buf); std::wstring sr = r; if (sr.empty()) { r = uuid + (sicon.empty() ? L"" : (L";" + sicon)); break; } size_t sep = sr.find(L';'); std::wstring olduuid = sep != std::wstring::npos ? sr.substr(0, sep) : sr; if (olduuid.compare(uuid) == 0) { if (bRemoveicon) r = uuid; // reset icon path in registry else if (!sicon.empty()) r = uuid + (sicon.empty() ? L"" : (L";" + sicon)); else sicon = sep != std::wstring::npos ? sr.substr(sep + 1) : L""; break; } foundUUIDIndex++; } while (foundUUIDIndex < 20); if (foundUUIDIndex >= 20) { CRegStdString r = CRegStdString(L"Software\\TortoiseGit\\LastUsedUUIDsForGrouping\\1"); r.removeKey(); } HICON icon = nullptr; if (!sicon.empty()) { if (sicon.size() >=4 && !_wcsicmp(sicon.substr(sicon.size() - 4).c_str(), L".ico")) { icon = (HICON)::LoadImage(NULL, sicon.c_str(), IMAGE_ICON, 16, 16, LR_LOADFROMFILE | LR_SHARED); } else { ULONG_PTR gdiplusToken = 0; Gdiplus::GdiplusStartupInput gdiplusStartupInput; GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, nullptr); if (gdiplusToken) { Gdiplus::Bitmap *pBitmap = new Gdiplus::Bitmap(sicon.c_str(), FALSE); if (pBitmap->GetLastStatus() == Gdiplus::Status::Ok) pBitmap->GetHICON(&icon); delete pBitmap; Gdiplus::GdiplusShutdown(gdiplusToken); } } } if (!icon) { DWORD colors[6] = {0x80FF0000, 0x80FFFF00, 0x8000FF00, 0x800000FF, 0x80000000, 0x8000FFFF}; // AND mask - monochrome - determines which pixels get drawn BYTE AND[32]; for( int i=0; i<32; i++ ) { AND[i] = 0xFF; } // XOR mask - 32bpp ARGB - determines the pixel values DWORD XOR[256]; for( int i=0; i<256; i++ ) { XOR[i] = colors[foundUUIDIndex % 6]; } icon = ::CreateIcon(NULL,16,16,1,32,AND,(BYTE*)XOR); } pTaskbarInterface->SetOverlayIcon(hWnd, icon, uuid.c_str()); pTaskbarInterface->Release(); DestroyIcon(icon); } } } } }
void SetUUIDOverlayIcon( HWND hWnd ) { if (CRegStdDWORD(_T("Software\\TortoiseGit\\GroupTaskbarIconsPerRepo"), 3)) { if (CRegStdDWORD(_T("Software\\TortoiseGit\\GroupTaskbarIconsPerRepoOverlay"), TRUE)) { std::wstring uuid; #ifdef _MFC_VER uuid = g_sGroupingUUID; #else CCmdLineParser parser(GetCommandLine()); if (parser.HasVal(L"groupuuid")) uuid = parser.GetVal(L"groupuuid"); #endif if (!uuid.empty()) { ITaskbarList3 * pTaskbarInterface = NULL; HRESULT hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_ITaskbarList3, reinterpret_cast<void**> (&(pTaskbarInterface))); if (SUCCEEDED(hr)) { int foundUUIDIndex = 0; do { wchar_t buf[MAX_PATH]; swprintf_s(buf, _countof(buf), L"%s%d", L"Software\\TortoiseGit\\LastUsedUUIDsForGrouping\\", foundUUIDIndex); CRegStdString r = CRegStdString(buf); std::wstring sr = r; if (sr.empty() || (sr.compare(uuid)==0)) { r = uuid; break; } foundUUIDIndex++; } while (foundUUIDIndex < 20); if (foundUUIDIndex >= 20) { CRegStdString r = CRegStdString(L"Software\\TortoiseGit\\LastUsedUUIDsForGrouping\\1"); r.removeKey(); } DWORD colors[6] = {0x80FF0000, 0x80FFFF00, 0x8000FF00, 0x800000FF, 0x80000000, 0x8000FFFF}; // AND mask - monochrome - determines which pixels get drawn BYTE AND[32]; for( int i=0; i<32; i++ ) { AND[i] = 0xFF; } // XOR mask - 32bpp ARGB - determines the pixel values DWORD XOR[256]; for( int i=0; i<256; i++ ) { XOR[i] = colors[foundUUIDIndex % 6]; } HICON icon = ::CreateIcon(NULL,16,16,1,32,AND,(BYTE*)XOR); pTaskbarInterface->SetOverlayIcon(hWnd, icon, uuid.c_str()); pTaskbarInterface->Release(); DestroyIcon(icon); } } } } }
void SetProgressValEx(HWND hWnd, ULONGLONG Completed, ULONGLONG Total) { ITaskbarList3 *taskbar; if(S_OK != CoCreateInstance(CLSID_TaskbarList, 0, CLSCTX_INPROC_SERVER, IID_ITaskbarList3, (void**)&taskbar)) return; taskbar->HrInit(); taskbar->SetProgressValue(hWnd, Completed, Total); taskbar->Release(); }