CXTPSkinManager::CXTPSkinManager() { ::InitializeCriticalSection(&m_csObjects); m_pSchema = NULL; m_bEnabled = FALSE; m_pResourceFile = new CXTPSkinManagerResourceFile(this); m_pClassMap = new CXTPSkinObjectClassMap(); m_pClassMap->AddStandardClasses(); m_mapObjects.InitHashTable(199, FALSE); m_bAutoApplyWindows = TRUE; m_bAutoApplyThreads = TRUE; m_dwApplyOptions = xtpSkinApplyFrame | xtpSkinApplyColors | xtpSkinApplyMetrics | xtpSkinApplyMenus; m_dwComCtrl = XTPSystemVersion()->GetComCtlVersion(); m_bWin9x = XTPSystemVersion()->IsWin9x(); m_hWinEventHook = NULL; m_pSetWinEventHook = NULL; m_pUnhookWinEvent = NULL; CXTPSkinManagerApiHook* pApiHook = CXTPSkinManagerApiHook::GetInstance(); pApiHook; HMODULE hLib = GetModuleHandle(_T("USER32")); if (hLib) { m_pSetWinEventHook = (LPFNSETWINEVENTHOOK)GetProcAddress(hLib, "SetWinEventHook"); m_pUnhookWinEvent = (LPFNUNHOOKWINEVENT)GetProcAddress(hLib, "UnhookWinEvent"); if (m_pSetWinEventHook && m_pUnhookWinEvent) { m_hWinEventHook = m_pSetWinEventHook(EVENT_OBJECT_REORDER, EVENT_OBJECT_REORDER, NULL, &CXTPSkinManager::WinEventProc, GetCurrentProcessId(), 0, 0); } } EnableCurrentThread(); #ifdef _AFXDLL m_pModuleState = AfxGetModuleState(); #endif }
void CXTPSplitterWndTheme::DrawSplitter(CDC* pDC, CXTPSplitterWnd* pSplitter, int nType, const CRect& rectArg) { CRect rect = rectArg; // draw the borders. switch (nType) { case splitBorder: pDC->Draw3dRect(rect, pSplitter->IsBorderVisible() ? m_crOuterBorder.clrDark : m_crBack, pSplitter->IsBorderVisible() ? m_crOuterBorder.clrLight : m_crBack); rect.InflateRect(-CX_BORDER, -CY_BORDER); pDC->Draw3dRect(rect, pSplitter->IsBorderVisible() ? m_crInnerBorder.clrDark : m_crBack, pSplitter->IsBorderVisible() ? m_crInnerBorder.clrLight : m_crBack); return; case splitIntersection: ASSERT(!XTPSystemVersion()->IsWin95OrGreater()); break; case splitBox: pDC->Draw3dRect(rect, m_crOuterBoxBorder.clrLight, m_crOuterBoxBorder.clrDark); rect.InflateRect(-CX_BORDER, -CY_BORDER); pDC->Draw3dRect(rect, m_crInnerBoxBorder.clrLight, m_crInnerBoxBorder.clrDark); rect.InflateRect(-CX_BORDER, -CY_BORDER); pDC->FillSolidRect(&rect, m_crBoxBack.clrDark); return; case splitBar: break; default: ASSERT(FALSE); // unknown splitter type } // fill the background. pDC->FillSolidRect(&rect, m_crBack.clrDark); }
void CXTPShellTreeView::OnInitialUpdate() { CTreeView::OnInitialUpdate(); // mimic native Windows Explorer styles. DWORD dwStyle = TVS_SHOWSELALWAYS | TVS_HASBUTTONS; if (XTPSystemVersion()->IsWinXPOrGreater()) { dwStyle |= (TVS_TRACKSELECT); } else { dwStyle |= (TVS_HASLINES | TVS_LINESATROOT); } if (InitializeTree(dwStyle)) { PopulateTreeView(); } // make the parent of the selected item visible if found. HTREEITEM hItem = GetTreeCtrl().GetSelectedItem(); HTREEITEM hItemParent = GetTreeCtrl().GetParentItem(hItem); GetTreeCtrl().EnsureVisible(hItemParent ? hItemParent : hItem); }
bool CXTPShellTreeCtrl::Init() { if (!CXTPShellTreeCtrlBase::Init()) return false; if (m_bAutoInit) { // mimic native Windows Explorer styles. DWORD dwStyle = TVS_SHOWSELALWAYS | TVS_HASBUTTONS; if (XTPSystemVersion()->IsWinXPOrGreater()) { dwStyle |= (TVS_TRACKSELECT); } else { dwStyle |= (TVS_HASLINES | TVS_LINESATROOT); } if (InitializeTree(dwStyle)) { PopulateTreeView(); } // make the parent of the selected item visible if found. HTREEITEM hItem = GetSelectedItem(); HTREEITEM hItemParent = GetParentItem(hItem); EnsureVisible(hItemParent ? hItemParent : hItem); } return true; }
void CXTPTabPaintManager::SetFontIndirect(LOGFONT* pLogFont, BOOL bUseStandardFont /*= FALSE*/) { m_bUseStandardFont = bUseStandardFont; if (!pLogFont) return; if (m_bClearTypeTextQuality && XTPSystemVersion()->IsClearTypeTextQualitySupported()) { pLogFont->lfQuality = 5; } m_fntNormal.DeleteObject(); m_fntBold.DeleteObject(); m_fntVerticalNormal.DeleteObject(); m_fntVerticalBold.DeleteObject(); pLogFont->lfWeight = m_bBoldNormal ? FW_BOLD : FW_NORMAL; VERIFY(m_fntNormal.CreateFontIndirect(pLogFont)); pLogFont->lfWeight = FW_BOLD; VERIFY(m_fntBold.CreateFontIndirect(pLogFont)); STRCPY_S(pLogFont->lfFaceName, LF_FACESIZE, CXTPDrawHelpers::GetVerticalFontName(FALSE)); pLogFont->lfOrientation = 900; pLogFont->lfEscapement = 2700; pLogFont->lfHeight = pLogFont->lfHeight < 0 ? __min(-11, pLogFont->lfHeight) : pLogFont->lfHeight; pLogFont->lfWeight = m_bBoldNormal ? FW_BOLD : FW_NORMAL; VERIFY(m_fntVerticalNormal.CreateFontIndirect(pLogFont)); pLogFont->lfWeight = FW_BOLD; VERIFY(m_fntVerticalBold.CreateFontIndirect(pLogFont)); }
void CXTPPopupControl::SetLayoutRTL(BOOL bRightToLeft) { if (XTPSystemVersion()->IsLayoutRTLSupported()) { m_bRightToLeft = bRightToLeft; } }
void CXTPMDIWndTab::InitializeFont() { HGDIOBJ hFont = XTPAuxData().font.GetSafeHandle(); // if the tabs are vertical, use the vertical menu font. if ((GetStyle() & TCS_VERTICAL) == TCS_VERTICAL) hFont = XTPAuxData().fontVert.GetSafeHandle(); if (hFont != NULL) { if (XTPSystemVersion()->IsWin95()) PostMessage(WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0)); else SendMessage(WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0)); } }
void CXTPShortcutBarPopup::DoModal() { int nClassStyle = 0; if (XTPSystemVersion()->IsWinXPOrGreater()) nClassStyle |= 0x00020000; CreateEx(WS_EX_TOOLWINDOW, AfxRegisterWndClass(nClassStyle, AfxGetApp()->LoadStandardCursor(IDC_ARROW)), 0, MFS_SYNCACTIVE | WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, CRect(0, 0, 0, 0), m_pShortcutBar, 0); CXTPWindowRect rcShortcutBar(m_pShortcutBar); CRect rc(rcShortcutBar.right, rcShortcutBar.top, rcShortcutBar.right + m_nPopupWidth + FRAME_GAP + FRAME_GAP, rcShortcutBar.bottom); SetWindowPos(0, rc.left, rc.top, rc.Width(), rc.Height(), SWP_NOZORDER | SWP_SHOWWINDOW); ::SetParent(m_hWndChild, m_hWnd); ::SetWindowPos(m_hWndChild, 0, FRAME_GAP, FRAME_GAP, rc.Width() - FRAME_GAP - FRAME_GAP, rc.Height() - FRAME_GAP - FRAME_GAP, SWP_NOZORDER | SWP_SHOWWINDOW); ::SetFocus(m_hWndChild); PumpMessage(); if (m_hWndChild) { ::SetParent(m_hWndChild, m_pShortcutBar->GetSafeHwnd()); ::ShowWindow(m_hWndChild, SW_HIDE); m_hWndChild = NULL; } m_nPopupWidth = CXTPWindowRect(this).Width() - FRAME_GAP - FRAME_GAP; DestroyWindow(); }
BOOL CXTPCalendarTimeZones::InitFromRegistry() { m_arTZInfo.RemoveAll(); CString strTZIRootKey = XTP_CALENDAR_TIMEZONESKEY_NT; HKEY hkTZIRoot = NULL; BOOL bUseIndex = !XTPSystemVersion()->IsWinXPOrGreater(); // Try NT information first LONG lRes = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, strTZIRootKey, 0, KEY_READ, &hkTZIRoot); if (lRes != ERROR_SUCCESS) { // try Win9x information strTZIRootKey = XTP_CALENDAR_TIMEZONESKEY_9X; bUseIndex = FALSE; lRes = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, strTZIRootKey, 0, KEY_READ, &hkTZIRoot); if (lRes != ERROR_SUCCESS) { TRACE(_T("Cannot open Time Zones information registry key. err = %d \n"), lRes); return FALSE; } } const DWORD cdwKeyBufSize = 1024; TCHAR szTZIKey[cdwKeyBufSize + 1]; BSTR bstrStandardName = NULL; BSTR bstrDaylightName = NULL; lRes = ERROR_SUCCESS; for (DWORD dwEnumKey = 0; lRes == ERROR_SUCCESS; dwEnumKey++) { ::ZeroMemory(szTZIKey, sizeof(szTZIKey)); lRes = ::RegEnumKey (hkTZIRoot, dwEnumKey, szTZIKey, cdwKeyBufSize); if (lRes != ERROR_SUCCESS) { ASSERT(lRes == ERROR_NO_MORE_ITEMS); break; } //=================================================================== CString strTZIKey = strTZIRootKey + _T("\\") + szTZIKey; HKEY hkTZIdata = NULL; LONG lRes2 = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, strTZIKey, 0, KEY_READ, &hkTZIdata); if (lRes2 != ERROR_SUCCESS) { TRACE(_T("Cannot open registry key 'HKEY_LOCAL_MACHINE\\%s'. err = %d \n"), (LPCTSTR)strTZIKey, lRes2); continue; } CString strDisplayStr, strStandardName, strDaylightName; DWORD dwIndex; REGISTRY_TIMEZONE_INFORMATION regTZI; if (!GetRegStr(hkTZIdata, XTP_CALENDAR_TZIRegValName_DisplayStr, strDisplayStr)) { TRACE(_T("Cannot get value from registry: 'HKEY_LOCAL_MACHINE\\%s\\%s'\n"), (LPCTSTR)strTZIKey, XTP_CALENDAR_TZIRegValName_DisplayStr); continue; } if (!GetRegBSTR(hkTZIdata, XTP_CALENDAR_TZIRegValName_StandardNameW, bstrStandardName)) { TRACE(_T("Cannot get value from registry: 'HKEY_LOCAL_MACHINE\\%s\\%s'\n"), (LPCTSTR)strTZIKey, XTP_CALENDAR_TZIRegValName_StandardName); continue; } if (!GetRegBSTR(hkTZIdata, XTP_CALENDAR_TZIRegValName_DaylightNameW, bstrDaylightName)) { TRACE(_T("Cannot get value from registry: 'HKEY_LOCAL_MACHINE\\%s\\%s'\n"), (LPCTSTR)strTZIKey, XTP_CALENDAR_TZIRegValName_DaylightName); continue; } if (!GetRegTZI(hkTZIdata, XTP_CALENDAR_TZIRegValName_DATA, regTZI)) { TRACE(_T("Cannot get value from registry: 'HKEY_LOCAL_MACHINE\\%s\\%s'\n"), (LPCTSTR)strTZIKey, XTP_CALENDAR_TZIRegValName_DATA); continue; } if (!GetRegDWORD(hkTZIdata, XTP_CALENDAR_TZIRegValName_Index, dwIndex)) { if (bUseIndex) { TRACE(_T("Cannot get value from registry: 'HKEY_LOCAL_MACHINE\\%s\\%s'\n"), (LPCTSTR)strTZIKey, XTP_CALENDAR_TZIRegValName_Index); } dwIndex = 0; } //================================================= CXTPCalendarTimeZone* pXTP_TZI; pXTP_TZI = new CXTPCalendarTimeZone(); if (!pXTP_TZI) { AfxThrowOleException(E_OUTOFMEMORY); } pXTP_TZI->Bias = regTZI.Bias; WCSNCPY_S(pXTP_TZI->StandardName, 32, bstrStandardName, 32); pXTP_TZI->StandardName[_countof(pXTP_TZI->StandardName)-1] = L'\0'; pXTP_TZI->StandardDate = regTZI.StandardDate; pXTP_TZI->StandardBias = regTZI.StandardBias; WCSNCPY_S(pXTP_TZI->DaylightName, 32, bstrDaylightName, 32); pXTP_TZI->DaylightName[_countof(pXTP_TZI->DaylightName)-1] = L'\0'; pXTP_TZI->DaylightDate = regTZI.DaylightDate; pXTP_TZI->DaylightBias = regTZI.DaylightBias; pXTP_TZI->m_strDisplayString = strDisplayStr; pXTP_TZI->m_dwIndex = dwIndex; m_arTZInfo.Add(pXTP_TZI, FALSE); RegCloseKey(hkTZIdata); } RegCloseKey(hkTZIRoot); //----------------------------------------------- if (bstrStandardName) { ::SysFreeString(bstrStandardName); } if (bstrDaylightName) { ::SysFreeString(bstrDaylightName); } //----------------------------------------------- int nCount = m_arTZInfo.GetCount(); for (int i = 0; i < nCount; i++) { for (int j = i + 1; j < nCount; j++) { CXTPCalendarTimeZonePtr ptrElem1, ptrElem2; ptrElem1 = m_arTZInfo.GetAt(i, TRUE); ptrElem2 = m_arTZInfo.GetAt(j, TRUE); if (CompareTZI(ptrElem1, ptrElem2, bUseIndex) > 0) { m_arTZInfo.SetAt(i, ptrElem2.Detach()); m_arTZInfo.SetAt(j, ptrElem1.Detach()); } } } return TRUE; }
void CXTPPropertyGridInplaceList::Create(CXTPPropertyGridItem* pItem, CRect rect) { ASSERT(pItem && pItem->GetGrid()); if (!pItem) return; CRect rcValue(rect); rcValue.left = pItem->GetGrid()->GetDividerPos() + 1; CWnd* pParent = (CWnd*)pItem->GetGrid(); m_pItem = pItem; DestroyWindow(); if (!m_hWnd) { CListBox::CreateEx(WS_EX_TOOLWINDOW | (pParent->GetExStyle() & WS_EX_LAYOUTRTL), _T("LISTBOX"), _T(""), LBS_NOTIFY | WS_CHILD | WS_VSCROLL | WS_BORDER | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS, CRect(0, 0, 0, 0), pParent, 0); SetOwner(pParent); if (m_bShowShadow && XTPSystemVersion()->IsWinXPOrGreater()) SetClassLongPtr(m_hWnd, GCL_STYLE, GetClassLongPtr(m_hWnd, GCL_STYLE) | 0x00020000); } SetFont(pParent->GetFont()); ResetContent(); CXTPPropertyGridItemConstraints* pList = pItem->GetConstraints(); int dx = rect.right - rcValue.left; CWindowDC dc(pParent); CXTPFontDC font(&dc, pParent->GetFont()); int nHeight = dc.GetTextExtent(_T(" "), 1).cy + 3; for (int i = 0; i < pList->GetCount(); i++) { CXTPPropertyGridItemConstraint* pConstraint = pList->GetConstraintAt(i); CString str = pConstraint->m_strConstraint; int nIndex = AddString(str); SetItemDataPtr(nIndex, pConstraint); CSize sz = pItem->OnMergeItemConstraint(&dc, pConstraint); dx = max(dx, sz.cx); nHeight = max(nHeight, sz.cy); if (pItem->GetValue() == str) SetCurSel(nIndex); } SetItemHeight(0, nHeight); rect.top = rect.bottom; rect.bottom += nHeight * __min(pItem->GetDropDownItemCount(), GetCount()) + 2; rect.left = rect.right - __min(dx, rect.Width() - XTP_PGI_EXPAND_BORDER); pParent->ClientToScreen(&rect); CRect rcWork = XTPMultiMonitor()->GetWorkArea(rect); if (rect.bottom > rcWork.bottom && rect.top > rcWork.CenterPoint().y) { rect.OffsetRect(0, - rect.Height() - rcValue.Height() - 1); } if (rect.left < rcWork.left) rect.OffsetRect(rcWork.left - rect.left, 0); if (rect.right > rcWork.right) rect.OffsetRect(rcWork.right - rect.right, 0); SetFocus(); SetWindowLongPtr(m_hWnd, GWLP_HWNDPARENT, 0); ModifyStyle(WS_CHILD, WS_POPUP); SetWindowLongPtr(m_hWnd, GWLP_HWNDPARENT, (LONG_PTR)pParent->m_hWnd); SetWindowPos(&CWnd::wndTopMost, rect.left, rect.top, rect.Width(), rect.Height(), SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOOWNERZORDER); CXTPMouseMonitor::SetupHook(this); }
void CXTPSkinObjectHeader::OnDraw(CDC* pDC) { CXTPClientRect rcClient(this); CRect rcBackground(rcClient); CXTPBufferDC dc(*pDC, rcClient); BOOL bFilterBar = (GetStyle() & HDS_FILTERBAR) && XTPSystemVersion()->GetComCtlVersion() >= MAKELONG(80, 5); CRect rcFilter(0, 0, 0, 0); dc.FillSolidRect(rcClient, GetColor(COLOR_3DFACE)); if (bFilterBar) { INT cyFilter = (rcClient.Height() - 1)/2; rcFilter = rcClient; rcClient.bottom = rcClient.top + cyFilter; rcFilter.top = rcClient.bottom; DefWindowProc(WM_PAINT, (WPARAM)dc.GetSafeHdc(), 0); } CXTPSkinManagerClass* pClass = GetSkinClass(); CXTPFontDC fontDC(&dc, GetFont()); dc.SetTextColor(GetColor(COLOR_BTNTEXT)); dc.SetBkMode(TRANSPARENT); CHeaderCtrl* pHeaderCtrl = (CHeaderCtrl*)this; int iItemCount = pHeaderCtrl->GetItemCount(); // Draw each header item for (int iItem = 0; iItem < iItemCount; ++iItem) { int nIndex = Header_OrderToIndex(m_hWnd, iItem); // initialize draw item structure. CRect rcItem(0, 0, 0, 0); Header_GetItemRect(m_hWnd, nIndex, &rcItem); if ((rcItem.right < rcClient.left) || (rcItem.left > rcClient.right)) continue; if (bFilterBar) { rcItem.bottom = rcFilter.top; } int nState = HIS_NORMAL; if (nIndex == m_nHotItem) { nState = m_bLBtnDown ? HIS_PRESSED : HIS_HOT; } rcBackground.left = max(rcBackground.left, rcItem.right); pClass->DrawThemeBackground(&dc, HP_HEADERITEM, nState, &rcItem); DrawItemEntry(&dc, nIndex, rcItem, nState); } if (rcBackground.left < rcBackground.right) pClass->DrawThemeBackground(&dc, 0, 0, &rcBackground); }