int CMainFrame::OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl) { if (lpCreateControl->nID == ID_VIEW_OFFICE_THEME) { CXTPControlComboBox* pComboTheme = (CXTPControlComboBox*)CXTPControlComboBox::CreateObject(); pComboTheme->SetCaption(_T("Theme:")); pComboTheme->AssignDocTemplate(IDR_MAINFRAME); pComboTheme->SetStyle(xtpComboLabel); pComboTheme->SetWidth(200); //pComboTheme->SetDropDownWidth(pComboTheme->GetWidth()); pComboTheme->SetFlags(xtpFlagManualUpdate); int nIndex = pComboTheme->AddString(_T("Office 2000")); pComboTheme->SetItemData(nIndex, xtpCalendarThemeOffice2000); nIndex = pComboTheme->AddString(_T("Office XP")); pComboTheme->SetItemData(nIndex, xtpCalendarThemeOfficeXP); nIndex = pComboTheme->AddString(_T("Office 2003")); pComboTheme->SetItemData(nIndex, xtpCalendarThemeOffice2003); int nIndexBlue = pComboTheme->AddString(_T("Office 2007 (Blue)")); pComboTheme->SetItemData(nIndexBlue, xtpCalendarThemeOffice2007); // 0 - Blue, 1 - Silver, 2 - Black if (FILEEXISTS_S(_GetTheme2007Style_file(1))) { nIndex = pComboTheme->AddString(_T("Office 2007 (Silver)")); pComboTheme->SetItemData(nIndex, xtpCalendarThemeOffice2007 + 100 + 1); } if (FILEEXISTS_S(_GetTheme2007Style_file(2))) { nIndex = pComboTheme->AddString(_T("Office 2007 (Black)")); pComboTheme->SetItemData(nIndex, xtpCalendarThemeOffice2007 + 100 + 2); } lpCreateControl->pControl = pComboTheme; pComboTheme->SetCurSel(nIndexBlue); return TRUE; } return FALSE; }
CXTPSkinImage* CXTPSkinManagerResourceFile::LoadImage(CString strImageFile) { CXTPSkinImage* pImage = NULL; if (m_pIniFile) { strImageFile = m_strResourcePath + _T('\\') + strImageFile; if (!FILEEXISTS_S(strImageFile)) return NULL; pImage = new CXTPSkinImage(); if (!pImage->LoadFile(strImageFile)) { delete pImage; return NULL; } } else { strImageFile.Replace(_T('.'), _T('_')); strImageFile.Replace(_T('\\'), _T('_')); pImage = new CXTPSkinImage(); if (!pImage->LoadFile(GetModuleHandle(), strImageFile)) { delete pImage; return NULL; } } return pImage; }
void CMainFrame::OnOfficeThemeChanged(NMHDR* pNMHDR, LRESULT* pResult) { NMXTPCONTROL* tagNMCONTROL = (NMXTPCONTROL*)pNMHDR; CXTPControlComboBox* pControl = (CXTPControlComboBox*)tagNMCONTROL->pControl; ASSERT(pControl->GetType() == xtpControlComboBox); if (pControl->GetType() != xtpControlComboBox) { ASSERT(FALSE); return; } int nCurSel = pControl->GetCurSel(); if (nCurSel < 0 || nCurSel >= pControl->GetCount()) { ASSERT(FALSE); return; } int nTheme = (int)pControl->GetItemData(nCurSel); #ifdef _DEBUG if ((GetKeyState(VK_SHIFT) & 0x8000) && (GetKeyState(VK_CONTROL) & 0x8000)) { if (FILEEXISTS_S(_GetTheme2007Style_file(3))) { int nIndex = pControl->AddString(_T("Office 2007 (Aqua)")); pControl->SetItemData(nIndex, xtpCalendarThemeOffice2007 + 100 + 3); pControl->SetCurSel(nIndex); nTheme = xtpCalendarThemeOffice2007 + 100 + 3; } } #endif SetOfficeTheme(nTheme); *pResult = 1; }
BOOL CXTPSkinManagerResourceFile::Open(LPCTSTR lpszResourcePath, LPCTSTR lpszIniFileName) { Close(); m_strResourcePath = lpszResourcePath; m_strIniFileName = lpszIniFileName; if (m_hInstance == NULL) { if (m_strResourcePath.IsEmpty()) return FALSE; CString strFileName = m_strResourcePath + _T('\\') + m_strIniFileName; if (!m_strIniFileName.IsEmpty() && FILEEXISTS_S(strFileName)) { m_pIniFile = new CStdioFile; if (!m_pIniFile->Open(strFileName, CFile::modeRead)) { SAFE_DELETE(m_pIniFile); return FALSE; } return TRUE; } m_hModule = LoadLibrary(lpszResourcePath); if (!m_hModule) { m_hModule = LoadLibraryEx(lpszResourcePath, NULL, LOAD_LIBRARY_AS_DATAFILE); } } else { m_hModule = m_strIniFileName.IsEmpty() ? NULL : m_hInstance; } if (!m_hModule) { return FALSE; } if (m_strIniFileName.IsEmpty()) { m_strIniFileName = GetDefaultIniFileName(); } CString strFilePath(m_strIniFileName); strFilePath.Replace(_T('.'), _T('_')); strFilePath.Replace(_T('\\'), _T('_')); HRSRC hRsrc = FindResource(m_hModule, strFilePath, _T("TEXTFILE")); if (!hRsrc) return FALSE; HGLOBAL hResData = LoadResource(m_hModule, hRsrc); if (!hResData) return FALSE; m_lpTextFile = (LPWSTR)LockResource(hResData); m_lpTextFileEnd = m_lpTextFile + SizeofResource(m_hModule, hRsrc)/2; if (m_lpTextFile && m_lpTextFile[0] == 0xFEFF) m_lpTextFile++; return TRUE; }