//********************************************************************* void CCxNDArrayDimGrid::SetRowHeight () { if (m_bIsPrinting) { ASSERT_VALID (m_pPrintDC); // map to printer metrics HDC hDCFrom = ::GetDC(NULL); int nYMul = m_pPrintDC->GetDeviceCaps(LOGPIXELSY); // pixels in print dc int nYDiv = ::GetDeviceCaps(hDCFrom, LOGPIXELSY); // pixels in screen dc ::ReleaseDC(NULL, hDCFrom); TEXTMETRIC tm; m_pPrintDC->GetTextMetrics (&tm); m_PrintParams.m_nRowHeight = tm.tmHeight + ::MulDiv (2 * TEXT_VMARGIN, nYMul, nYDiv); m_PrintParams.m_nLargeRowHeight = m_PrintParams.m_nRowHeight; } else { CClientDC dc (this); HFONT hfontOld = SetCurrFont (&dc); TEXTMETRIC tm; dc.GetTextMetrics (&tm); m_nRowHeight = tm.tmHeight + 2 * TEXT_VMARGIN; m_nLargeRowHeight = m_nRowHeight; ::SelectObject (dc.GetSafeHdc (), hfontOld); } }
//**************************************************************************************** void CBCGPColorButton::RebuildPalette (CPalette* pPal) { if (m_pPalette != NULL) { delete m_pPalette; } m_pPalette = new CPalette (); // Create palette: CClientDC dc (this); if (pPal == NULL) { int nColors = 256; // Use 256 first entries UINT nSize = sizeof(LOGPALETTE) + (sizeof(PALETTEENTRY) * nColors); LOGPALETTE *pLP = (LOGPALETTE *) new BYTE[nSize]; ::GetSystemPaletteEntries (dc.GetSafeHdc (), 0, nColors, pLP->palPalEntry); pLP->palVersion = 0x300; pLP->palNumEntries = (USHORT) nColors; m_pPalette->CreatePalette (pLP); delete[] pLP; } else { ASSERT_VALID (pPal); int nColors = pPal->GetEntryCount (); UINT nSize = sizeof(LOGPALETTE) + (sizeof(PALETTEENTRY) * nColors); LOGPALETTE *pLP = (LOGPALETTE *) new BYTE[nSize]; pPal->GetPaletteEntries (0, nColors, pLP->palPalEntry); pLP->palVersion = 0x300; pLP->palNumEntries = (USHORT) nColors; m_pPalette->CreatePalette (pLP); delete[] pLP; } }