Esempio n. 1
0
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.");
		}
	}
}
Esempio n. 2
0
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();
			}
		}
	}
Esempio n. 4
0
void CMainFrame::SetProgressBarState(TBPFLAG tbpFlags)
{
	ASSERT(::IsWindow(m_hWnd)); 

	if (!afxGlobalData.bIsWindows7)
	{
		return;
	}

	ITaskbarList3* pTaskbarList = GetITaskbarList3();
	ENSURE(pTaskbarList != NULL);

	pTaskbarList->SetProgressState(GetSafeHwnd(), tbpFlags);
}
Esempio n. 5
0
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();
}
Esempio n. 6
0
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();
}
Esempio n. 7
0
void CMainFrame::SetProgressBarPosition(int nProgressPos)
{
	ASSERT_VALID(this);

	if (!afxGlobalData.bIsWindows7)
	{
		return;
	}

	ITaskbarList3* pTaskbarList = GetITaskbarList3();
	ENSURE(pTaskbarList != NULL);

	pTaskbarList->SetProgressValue(GetSafeHwnd(), nProgressPos - m_nProgressBarRangeMin, 
		m_nProgressBarRangeMax - m_nProgressBarRangeMin);
}
Esempio n. 8
0
    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;
            }
        }
    }
Esempio n. 9
0
 void setProgress(WId w, quint64 completed, quint64 total)
 {
     if (m_taskbarInterface)
     {
        m_taskbarInterface->SetProgressValue(w, (completed < total)?completed:total, total);
     }
 }
Esempio n. 10
0
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();
}
Esempio n. 11
0
 void setOverlayIcon(WId w, const QIcon& icon, const QString& description)
 {
     if (m_taskbarInterface)
     {
         HICON overlay_icon = icon.isNull() ? NULL : icon.pixmap(48).toWinHICON();
         m_taskbarInterface->SetOverlayIcon(w, overlay_icon, description.toStdWString().c_str());
         if (overlay_icon)
         {
             DestroyIcon(overlay_icon);
         }
     }
 }
Esempio n. 12
0
bool Taskbar::createInterface(void)
{
	if(s_data && (!s_data->ptbl))
	{
		const HRESULT hrComInit = CoInitialize(NULL);

		if((hrComInit != S_OK) && (hrComInit != S_FALSE))
		{
			qWarning("CoInitialize() has failed!");
			return false;
		}

		ITaskbarList3 *tmp = NULL;
		const HRESULT hrCreate = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&tmp));

		if(!SUCCEEDED(hrCreate))
		{
			qWarning("ITaskbarList3 interface could not be created!");
			CoUninitialize();
			return false;
		}

		const HRESULT hrInitTaskbar = tmp->HrInit();

		if(!SUCCEEDED(hrInitTaskbar))
		{
			qWarning("ITaskbarList3::HrInit() has failed!");
			RELEASE(tmp);
			CoUninitialize();
			return false;
		}

		s_data->ptbl = tmp;
		return true;
	}

	qWarning("Interface was already created!");
	return false;
}
Esempio n. 13
0
 void setState(WId w, TBSTATE tb_state)
 {
     if (m_taskbarInterface)
     {
         switch(tb_state)
         {
         case S_INTERMEDIATE:
             m_taskbarInterface->SetProgressState(w, TBPF_INDETERMINATE);
             break;
         case S_NORM:
             m_taskbarInterface->SetProgressState(w, TBPF_NORMAL);
             break;
         case S_ERROR:
             m_taskbarInterface->SetProgressState(w, TBPF_ERROR);
             break;
         case S_PAUSED:
             m_taskbarInterface->SetProgressState(w, TBPF_PAUSED);
             break;
         default:
             m_taskbarInterface->SetProgressState(w, TBPF_NOPROGRESS);
             break;
         }
     }
 }
Esempio n. 14
0
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);
                }
            }
        }
    }
}
Esempio n. 15
0
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);
                }
            }
        }
    }
}
Esempio n. 16
0
 ~TaskBarIface()
 {
     if (m_taskbarInterface) m_taskbarInterface->Release();
 }
Esempio n. 17
-1
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();
}