本文整理汇总了C++中CFont::GetSafeHandle方法的典型用法代码示例。如果您正苦于以下问题:C++ CFont::GetSafeHandle方法的具体用法?C++ CFont::GetSafeHandle怎么用?C++ CFont::GetSafeHandle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFont
的用法示例。
在下文中一共展示了CFont::GetSafeHandle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateDefaultFont
//创建字体
bool __cdecl CSkinResource::CreateDefaultFont(CFont & Font)
{
//释放对象
ASSERT(Font.GetSafeHandle()==NULL);
if (Font.GetSafeHandle()!=NULL) Font.DeleteObject();
//创建字体
Font.CreateFont(-12,0,0,0,400,0,0,0,134,3,2,1,2,TEXT("宋体"));
ASSERT(Font.GetSafeHandle()!=NULL);
return (Font.GetSafeHandle()!=NULL);
}
示例2: Initialise
/*
* Method preamble ************************************************************
*
* CLASS: TFXDataTip
* NAME: Initialise
*
* DESCRIPTION: This method initialise the DataTip class. It creates the
* default font used for DataTips, the brush used to paint
* windows background, and registers the window class.
*
* If there is currently no hook procedure instaklled for
* the class it alos installs a keyboard hook procedure.
*
* PARAMETERS: none
*
* RETURN TYPE: void
*
******************************************************************************
* REVISION HISTORY
*
******************************************************************************
*/
void TFXDataTip::Initialise( )
{
if (_font.GetSafeHandle( ) == NULL)
{
// create the default tip font
LOGFONT lFont;
GetObject(GetStockObject(ANSI_FIXED_FONT), sizeof lFont, &lFont);
_font.CreateFontIndirect(&lFont);
// create the other GDI objects
//_brush = new CBrush(::GetSysColor(COLOR_INFOBK));
_brush = new CBrush( RGB(32,32,32) );
}
// register the window class
RegisterWnd( );
// install the keyboard hook procedure
if (_hookProc == NULL)
{
_hookProc = ::SetWindowsHookEx(WH_KEYBOARD,
(HOOKPROC)KeyboardHookCallback,
NULL,
::GetCurrentThreadId( ));
}
}
示例3: OnGetFont
LRESULT CProgressCtrlX::OnGetFont(WPARAM, LPARAM)
{
CFont* pFont = CProgress::GetFont();
if(!pFont)
return NULL;
return (LRESULT)pFont->GetSafeHandle();
}
示例4: PreSubclassWindow
/////////////////////////////////////////////////////////////////////////////////
//// PreSubclassWindow
void CxStatic::PreSubclassWindow()
{
//TRACE(_T("in CxStatic::PreSubclassWindow\n"));
m_dwTxtFlags = GetStyle();
ModifyStyle(SS_TYPEMASK, SS_OWNERDRAW);
// get current font
CFont* pFont = GetFont();
if (!pFont)
{
HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
if (hFont == NULL)
hFont = (HFONT) GetStockObject(ANSI_VAR_FONT);
if (hFont)
pFont = CFont::FromHandle(hFont);
}
ASSERT(pFont);
ASSERT(pFont->GetSafeHandle());
// create the font for this control
LOGFONT lf;
pFont->GetLogFont(&lf);
m_font.CreateFontIndirect(&lf);
this->GetWindowText(m_strText);
DragAcceptFiles(TRUE);
Invalidate();
}
示例5: PreSubclassWindow
void CQnStatic::PreSubclassWindow()
{
// We want to get mouse clicks via STN_CLICKED
DWORD dwStyle = GetStyle();
::SetWindowLong(GetSafeHwnd(), GWL_STYLE, dwStyle | SS_NOTIFY);
CFont* pFont = GetFont();
if (!pFont)
{
HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
if (hFont == NULL)
hFont = (HFONT) GetStockObject(ANSI_VAR_FONT);
if (hFont)
pFont = CFont::FromHandle(hFont);
}
ASSERT(pFont->GetSafeHandle());
// Create the underline font
LOGFONT lf;
pFont->GetLogFont(&lf);
lf.lfHeight = m_nFontSize;
lf.lfWeight = m_bBold?FW_BOLD:FW_NORMAL;
m_StdFont.CreateFontIndirect(&lf);
SetFont(&m_StdFont);
lf.lfUnderline = (BYTE) TRUE;
m_UnderlineFont.CreateFontIndirect(&lf);
SetDefaultCursor(); // Try and load up a "hand" cursor
CStatic::PreSubclassWindow();
}
示例6: DrawItem
void CPmwStatusBar::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CFont* pFont = GetFont();
CRect rcItem = lpDrawItemStruct->rcItem;
HDC hDC = lpDrawItemStruct->hDC;
CString csText;
GetPaneText(lpDrawItemStruct->itemID, csText);
int nBitmapIndex = lpDrawItemStruct->itemID-1;
if (m_Indicators[nBitmapIndex].m_fValid)
{
// We have a bitmap to draw.
CDC dcBitmap;
if (dcBitmap.CreateCompatibleDC(CDC::FromHandle(hDC)))
{
CBitmap* pOldBitmap = dcBitmap.SelectObject(&m_Indicators[nBitmapIndex].m_Bitmap);
if (pOldBitmap != NULL)
{
CRect r;
CSize Size = m_Indicators[nBitmapIndex].m_Size;
r.left = rcItem.left + 2;
r.right = r.left + Size.cx;
r.top = (lpDrawItemStruct->rcItem.top + lpDrawItemStruct->rcItem.bottom - Size.cy)/2;
r.bottom = r.top + Size.cy;
::BitBlt(hDC,
r.left,
r.top,
r.Width(),
r.Height(),
dcBitmap.GetSafeHdc(),
0,
0,
SRCCOPY);
dcBitmap.SelectObject(pOldBitmap);
rcItem.left = r.right + 2;
}
dcBitmap.DeleteDC();
}
}
HFONT hOldFont = (HFONT)::SelectObject(hDC, pFont->GetSafeHandle());
if (hOldFont != NULL)
{
int nOldMode = SetBkMode(hDC, TRANSPARENT);
::DrawText(hDC,
csText,
csText.GetLength(),
&rcItem,
DT_CENTER | DT_SINGLELINE | DT_VCENTER);
SetBkMode(hDC, nOldMode);
::SelectObject(hDC, hOldFont);
}
}
示例7:
CFont& GraphicsMisc::Marlett()
{
static CFont font;
if (!font.GetSafeHandle())
font.Attach(CreateFont(_T("Marlett"), -1, GMFS_SYMBOL));
return font;
}
示例8: CreateSafeFontIndirect
BOOL CXTPSyntaxEditPropertiesPageFont::CreateSafeFontIndirect(CFont& editFont, const LOGFONT& lf)
{
if (editFont.GetSafeHandle())
editFont.DeleteObject();
if (!editFont.CreateFontIndirect(&lf))
return FALSE;
return TRUE;
}
示例9: MeasureItem
void CQListCtrl::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
TEXTMETRIC tm;
HDC hDC = ::GetDC(NULL);
CFont* pFont = GetFont();
HFONT hFontOld = (HFONT)SelectObject(hDC, pFont->GetSafeHandle());
GetTextMetrics(hDC, &tm);
lpMeasureItemStruct->itemHeight = ((tm.tmHeight + tm.tmExternalLeading) * m_linesPerRow) + ROW_BOTTOM_BORDER;
SelectObject(hDC, hFontOld);
::ReleaseDC(NULL, hDC);
}
示例10: PreSubclassWindow
///////////////////////////////////////////////////////////////////////////////
// PreSubclassWindow
void CXHyperLink::PreSubclassWindow()
{
// We want to get mouse clicks via STN_CLICKED
DWORD dwStyle = GetStyle();
::SetWindowLong(GetSafeHwnd(), GWL_STYLE, dwStyle | SS_NOTIFY);
// Set the URL as the window text
if (m_strURL.IsEmpty())
GetWindowText(m_strURL);
// Check that the window text isn't empty. If it is, set it as the URL.
CString strWndText;
GetWindowText(strWndText);
if (strWndText.IsEmpty())
{
ASSERT(!m_strURL.IsEmpty()); // Window and URL both NULL. DUH!
SetWindowText(m_strURL);
}
CFont* pFont = GetFont();
if (!pFont)
{
HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
if (hFont == NULL)
hFont = (HFONT) GetStockObject(ANSI_VAR_FONT);
if (hFont)
pFont = CFont::FromHandle(hFont);
}
ASSERT(pFont->GetSafeHandle());
// Create the underline font
LOGFONT lf;
pFont->GetLogFont(&lf);
m_StdFont.CreateFontIndirect(&lf);
lf.lfUnderline = (BYTE) TRUE;
m_UnderlineFont.CreateFontIndirect(&lf);
PositionWindow(); // Adjust size of window to fit URL if necessary
SetDefaultCursor(); // Try and load up a "hand" cursor
SetUnderline();
// Create the tooltip
if (m_bToolTip)
{
CRect rect;
GetClientRect(rect);
m_ToolTip.Create(this);
m_ToolTip.AddTool(this, m_strURL, rect, TOOLTIP_ID);
}
CStatic::PreSubclassWindow();
}
示例11: EnsurePageCreated
BOOL CPropertyPageHost::EnsurePageCreated(int nIndex)
{
if (nIndex < 0 || nIndex >= m_aPages.GetSize())
return FALSE;
CPropertyPage* pPage = m_aPages[nIndex].pPage;
if (!pPage)
return FALSE;
if (pPage->GetSafeHwnd() == NULL) // first time only
{
if (!pPage->Create(pPage->m_psp.pszTemplate, this))
return FALSE;
// make sure we can into/out of the page
pPage->ModifyStyleEx(0, WS_EX_CONTROLPARENT | DS_CONTROL);
// make sure the page is a child and modify it if necessary
pPage->ModifyStyle(WS_POPUPWINDOW | WS_OVERLAPPEDWINDOW, 0);
if (!(pPage->GetStyle() & WS_CHILD))
{
pPage->ModifyStyle(0, WS_CHILD);
pPage->SetParent(this);
ASSERT (pPage->GetParent() == this);
}
// set font to our parent's font
CWnd* pOurParent = GetParent();
ASSERT (pOurParent);
CFont* pFont = pOurParent->GetFont();
if (pFont)
CDialogHelper::SetFont(pPage, (HFONT)pFont->GetSafeHandle(), FALSE);
// and our parent
pPage->SetParent(this);
// snapshot the pages original size
CRect rOrg;
pPage->GetClientRect(rOrg);
m_aPages[nIndex].sizeOrg = rOrg.Size();
// then fit to the current Host size
UpdatePageSize(nIndex);
}
return (pPage->GetSafeHwnd() != NULL);
}
示例12: GetSafeLogFont
BOOL CXTPSyntaxEditPropertiesPageFont::GetSafeLogFont(LOGFONT& lf)
{
if (m_editFont.GetSafeHandle())
{
m_editFont.GetLogFont(&lf);
return TRUE;
}
CFont* pFont = GetPaintManager() ? GetPaintManager()->GetFont() : NULL;
if (pFont && pFont->GetSafeHandle())
{
pFont->GetLogFont(&lf);
return TRUE;
}
return FALSE;
}
示例13: PreSubclassWindow
void CHyperLink::PreSubclassWindow()
{
// Enable notifications - CStatic has this disabled by default
DWORD dwStyle = GetStyle();
::SetWindowLong(GetSafeHwnd(), GWL_STYLE, dwStyle | SS_NOTIFY);
// By default use the label text as the URL
if (m_strURL.IsEmpty())
GetWindowText(m_strURL);
CString strWndText;
GetWindowText(strWndText);
if (strWndText.IsEmpty())
{
SetWindowText(m_strURL);
}
CFont* pFont = GetFont();
if (!pFont)
{
HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
if (hFont == NULL)
hFont = (HFONT) GetStockObject(ANSI_VAR_FONT);
if (hFont)
pFont = CFont::FromHandle(hFont);
}
ASSERT(pFont->GetSafeHandle());
LOGFONT lf;
pFont->GetLogFont(&lf);
m_StdFont.CreateFontIndirect(&lf);
lf.lfUnderline = (BYTE) TRUE;
m_UnderlineFont.CreateFontIndirect(&lf);
SetDefaultCursor(); // try loading a "hand" cursor
SetUnderline();
CRect rect;
GetClientRect(rect);
m_ToolTip.Create(this);
m_ToolTip.AddTool(this, m_strURL, rect, TOOLTIP_ID);
CStatic::PreSubclassWindow();
}
示例14: PreSubclassWindow
///////////////////////////////////////////////////////////////////////////////
// PreSubclassWindow
void CXColorStatic::PreSubclassWindow()
{
TRACE(_T("in CXColorStatic::PreSubclassWindow\n"));
// get current font
CFont* pFont = GetFont();
if (!pFont)
{
HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
if (hFont == NULL)
hFont = (HFONT) GetStockObject(ANSI_VAR_FONT);
if (hFont)
pFont = CFont::FromHandle(hFont);
}
ASSERT(pFont);
ASSERT(pFont->GetSafeHandle());
// create the font for this control
LOGFONT lf;
pFont->GetLogFont(&lf);
m_font.CreateFontIndirect(&lf);
}
示例15: DrawWatermarkBackground
void CXTPFlowGraphDrawContext::DrawWatermarkBackground(CRect rc)
{
LOGFONT lf = {0};
lf.lfHeight = LONG(rc.Width() * 80 / 1000);
lf.lfWeight = FW_BOLD;
STRCPY_S(lf.lfFaceName, LF_FACESIZE, _T("Myraid Pro"));
CFont font;
font.CreateFontIndirect(&lf);
HFONT hOldFont = (HFONT)SelectObject(m_hDC, font.GetSafeHandle());
SetTextColor(RGB(102, 102, 102));
::SetBkMode(m_hDC, TRANSPARENT);
::DrawText(m_hDC, _T("Codejock Chart Pro Trial"), -1, rc, DT_VCENTER | DT_CENTER | DT_SINGLELINE);
SelectObject(m_hDC, hOldFont);
}