示例#1
0
HRESULT DrawThemesPart(HDC hDC, int iPartId, int iStateId, LPCSTR uiPartNameID, LPRECT prcBox)
{
    if(!IsWinXP()) return E_FAIL;
    HINSTANCE hDll=LoadLibrary(CString((LPCTSTR)IDS_UTIL_UXTHEME));                                // 'UxTheme.dll'
    if(!hDll) return E_FAIL;

    BOOL (PASCAL* pfnIsThemeActive)();    UINT hTheme=0;
    (FARPROC&)pfnIsThemeActive=GetProcAddress(hDll,IDS_UTIL_THEMEACT);        // 'IsThemeActive'
    HRESULT hResult=E_FAIL;

    if(pfnIsThemeActive && pfnIsThemeActive())
    {    
        CString sPartName((LPCTSTR)uiPartNameID);
        if(sPartName.GetLength()>0)
        {    
            WCHAR swPartName[WPART_NAME_SZ];
#if !defined(UNICODE) && !defined(_UNICODE)
            MultiByteToWideChar(CP_ACP,0,(LPCSTR)sPartName,-1,swPartName,sizeof(swPartName)/sizeof(WCHAR));
#else
            _tcscpy(swPartName, sPartName.GetBuffer());
#endif
            UINT (PASCAL* pfnOpenThemeData)(HWND hwnd, LPCWSTR pszClassList);
            (FARPROC&)pfnOpenThemeData=GetProcAddress(hDll,IDS_UTIL_THEMEOPN);// 'OpenThemeData'
            if(pfnOpenThemeData && (hTheme=pfnOpenThemeData(NULL, swPartName))!=0)
            {    
                UINT (PASCAL* pfnDrawThemeBackground)(UINT htheme,HDC hdc,int iPartID,int iStateID,const RECT* prcBx,const RECT* prcClip);
                (FARPROC&)pfnDrawThemeBackground=GetProcAddress(hDll,IDS_UTIL_THEMEBCKG);    // 'DrawThemeBackground'
                if(pfnDrawThemeBackground)
                    hResult=pfnDrawThemeBackground(hTheme, hDC, iPartId, iStateId, prcBox, NULL);
            }    
        }    
    }
    FreeLibrary(hDll);
    return hResult;
}
示例#2
0
HRESULT CThemeHelperST::DrawThemeBackground(HTHEME hTheme, HWND hWnd, HDC hdc, int iPartId, int iStateId, const RECT* pRect, const RECT* pClipRect)
{
	if((pfnDrawThemeParentBackground != NULL) && (hWnd != NULL))
		pfnDrawThemeParentBackground(hWnd, hdc, (PRECT)pRect);  

	if(pfnDrawThemeBackground != NULL) return pfnDrawThemeBackground(hTheme, hdc, iPartId, iStateId, pRect, pClipRect);
	return E_FAIL;
}