本文整理汇总了C++中CClientDC::GetSafeHdc方法的典型用法代码示例。如果您正苦于以下问题:C++ CClientDC::GetSafeHdc方法的具体用法?C++ CClientDC::GetSafeHdc怎么用?C++ CClientDC::GetSafeHdc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CClientDC
的用法示例。
在下文中一共展示了CClientDC::GetSafeHdc方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetRowHeight
//*********************************************************************
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);
}
}
示例2: RebuildPalette
//****************************************************************************************
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;
}
}