1. 程式人生 > >Codejock Xtreme ToolkitPro v15.0 在HOOK控制元件後導致滾動條不正常bug及修復

Codejock Xtreme ToolkitPro v15.0 在HOOK控制元件後導致滾動條不正常bug及修復

介面庫的原理先搞清楚就好辦了,大部分都是採用HOOK WinProc來實現介面美化,所有先從HOOK開始入手,很多問題慢慢就清晰了...

這個深坑有幾個月了,一直沒閒功夫去認真閱讀它的整個程式碼框架,今天翻閱了一個小時,總算有點頭緒了,只需要一行程式碼即可解決~~

當然,它在WIN8.1/10上面還有無數的坑,原版CODEJOCK記得有不下10處需要改動,其他的慢慢調吧 偷笑 .....

實際上SetHook內部也過濾掉了很多類名,反正在這裡也過濾掉你自己的視窗類名就行了

CXTPSkinObject* CXTPSkinManager::SetHook(HWND hWnd, LPCTSTR lpszClassName, LPCREATESTRUCT lpcs, BOOL bAuto)
{
	if (_tcscmp(lpszClassName, _T("tooltips_class32")) == 0)
		return NULL;

	if (_tcsicmp(lpszClassName, _T("IME")) == 0)
		return NULL;

	if(_tcsicmp(lpszClassName,_T("CicMarshalWndClass"))== 0)
		return NULL;

	if(_tcsicmp(lpszClassName,_T("MSCTFIME UI"))== 0)
		return NULL;

	CXTPSkinObject* pSink = NULL;

	if (pSink == NULL && _tcsstr(lpszClassName, _T("WindowsForms")) != NULL)
	{

		CString strClass(lpszClassName);
		int nClassNameStart = strClass.Find(_T('.'));
		int nClassNameEnd = strClass.Find(_T('.'), nClassNameStart + 1);

		if (nClassNameStart != -1 && nClassNameEnd != -1 && nClassNameEnd != nClassNameStart)
		{
			strClass = strClass.Mid(nClassNameStart + 1, nClassNameEnd - nClassNameStart - 1);

			CXTPSkinObjectClassInfo* pInfo = m_pClassMap->Lookup(strClass);

			if (pInfo)
			{
				pSink = pInfo->CreateObject(lpszClassName, lpcs);
			}
		}

		if (pSink == NULL)
		{
			pSink = new CXTPSkinObjectApplicationFrame();
		}

		pSink->m_bWindowsForms = TRUE;
	}

	if (pSink == NULL)
	{
		CXTPSkinObjectClassInfo* pInfo = m_pClassMap->Lookup(lpszClassName);

		if (pInfo)
		{
			pSink = pInfo->CreateObject(lpszClassName, lpcs);
		}
		else
		{
			if (_tcsstr(lpszClassName, _T("Internet Explorer")) != NULL)
				return NULL;

			if (_tcsstr(lpszClassName, _T("OleMainThread")) != NULL)
				return NULL;

			pSink = new CXTPSkinObjectApplicationFrame();
		}
	}

	if (pSink && _tcscmp(lpszClassName, _T("#32770")) == 0)
	{
		((CXTPSkinObjectFrame*)pSink)->m_dwDialogTexture = IsTabPage(lpcs) ? ETDT_ENABLETAB : ETDT_ENABLE;
	}

	if (pSink)
	{

		pSink->m_pManager = this;
		{
			CXTPLockGuard lock(m_csObjects);
			m_mapObjects[hWnd] = pSink;
		}

		pSink->AttachHook(hWnd, lpcs, bAuto);
	}

	return pSink;
}