// /// Override TWindow virtual member function to paint the control. // void TUrlLink::Paint(TDC& dc, bool /*erase*/, TRect& /*rect*/) { TPointer<TFont> tmpFnt; // Object wrapping font handle TAPointer<tchar> text; // Pointer to caption dynamic buffer // Select the font if(!LinkFont){ HFONT hFont = HFONT(::SendMessage(::GetParent(*this), WM_GETFONT, 0, 0)); if (!hFont) hFont = HFONT(GetStockObject(ANSI_VAR_FONT)); if (hFont) tmpFnt = new TFont(hFont); } if (LinkFont) { CHECK(LinkFont->IsGDIObject()); dc.SelectObject(*LinkFont); } else if (tmpFnt) { CHECK(((TFont&)tmpFnt).IsGDIObject()); dc.SelectObject((TFont&)tmpFnt); } int len = GetWindowTextLength(); text = new tchar[len+1]; GetWindowText(text, len+1); TRect textRect; GetClientRect(textRect); TColor textColor = LinkColor; if (bOverControl) textColor = HoverColor; else if (bVisited) textColor = VisitedColor; TColor oldColor = dc.SetTextColor(textColor); int oldMode = dc.SetBkMode(TRANSPARENT); dc.DrawText(&text[0], len, textRect, 0); dc.SetBkMode(oldMode); dc.SetTextColor(oldColor); // Restore font if (LinkFont || tmpFnt) dc.RestoreFont(); }
void CMessageBox::OnFontChange() { CDialog::OnFontChange(); m_pFont=CFont::FromHandle(HFONT(GetStockObject(DEFAULT_GUI_FONT))); for(unsigned int i=0;i<ButtonCount();i++){ Button(i).SetFont(m_pFont); } m_pStaticText->SetFont(m_pFont); }
void CMessageBox::Init() { m_pFont=CFont::FromHandle(HFONT(GetStockObject(DEFAULT_GUI_FONT))); m_nFocusButton=-1; m_nEscapeButton=-1; m_nJustify=SS_LEFT; m_nDefaultButton=0; m_hIcon=NULL; m_pStaticText=NULL; m_pStaticIcon=NULL; m_bTopMost=false; m_bModeless=false; m_bDialogCreated=false; m_pParentNotify=NULL; m_crText=GetSysColor(COLOR_BTNTEXT); InitModalIndirect (&DlgData.tmpl,NULL); }
BOOL CThetaGridAdjustmentSimpleOutputDlg::OnInitDialog() { int i; CString T; BOOL b; CWnd* pWnd; CDC* pDC; pWnd=this; pWnd->CenterWindow(); if (m_nType==1) pWnd->SetWindowTextW(L"Simple Output - Event's Arguments"); //if dealing with the event's arguments else if (m_nType==2) pWnd->SetWindowTextW(L"Simple Output - Complement Clause"); //if dealing with the event's complement clause CDialog::OnInitDialog(); m_bSubjectRaised=FALSE; m_strTargetFontName=m_pDoc->GetTargetLanguageFontName(); //used in ChangeFont if (HFONT(m_fontTarget)==NULL) //first time this modeless dialog activated { //create the fonts that will be used in the combo boxes pWnd=&m_datatblInput; pDC=pWnd->GetDC(); //get a pointer to the device context T=m_pDoc->GetSourceLanguageFontName(4); b=m_fontArial.CreatePointFont(90,L"Arial",pDC); if (b==FALSE) AfxMessageBox(L"Unable to create Arial font.",MB_OK); i=m_pDoc->GetTargetLanguageFontSize(); b=m_fontTarget.CreatePointFont(10*i,m_strTargetFontName,pDC); if (b==FALSE) AfxMessageBox(L"Unable to create Target font.",MB_OK); } SetupTable(); if (m_nType==2) //if specifying features for object complement clause { pWnd=GetDlgItem(IDC_BUTTONFEATURESET); pWnd->MoveWindow(12,68,75,22); } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void CSkillEditListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { //draw selection background colour if( lpDrawItemStruct->itemState & ODS_SELECTED ) { FillRect( lpDrawItemStruct->hDC, &lpDrawItemStruct->rcItem, (HBRUSH)(COLOR_HIGHLIGHT+1) ); SetBkColor( lpDrawItemStruct->hDC, GetSysColor(COLOR_HIGHLIGHT) ); SetTextColor( lpDrawItemStruct->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT) ); } else { FillRect( lpDrawItemStruct->hDC, &lpDrawItemStruct->rcItem, (HBRUSH)(COLOR_WINDOW+1) ); SetBkColor( lpDrawItemStruct->hDC, GetSysColor(COLOR_WINDOW) ); SetTextColor( lpDrawItemStruct->hDC, GetSysColor(COLOR_WINDOWTEXT) ); } //draw the text CInvestigatorSkill* pInvestigatorSkill = (CInvestigatorSkill*)lpDrawItemStruct->itemData; if( pInvestigatorSkill ) { //set the font SetTextAlign( lpDrawItemStruct->hDC, TA_LEFT|VTA_BASELINE ); HFONT hFontOld = NULL; if( pInvestigatorSkill->m_fOccupational ) //draw occupational skills differently { //get the current font CFont* pFont = GetFont(); //get the LOGFONT and toggle bold LOGFONT lf; pFont->GetLogFont( &lf ); lf.lfWeight = ( lf.lfWeight == 0 || lf.lfWeight == FW_NORMAL || lf.lfWeight == FW_REGULAR ) ? FW_BOLD : FW_NORMAL; //create a new font based on it CFont NewFont; NewFont.CreateFontIndirect( &lf ); hFontOld = (HFONT)SelectObject( lpDrawItemStruct->hDC, HFONT(NewFont) ); } CString strText; if( pInvestigatorSkill->m_pSkill->m_SkillType == SUBSKILL ) { CSubSkill* pSubSkill = (CSubSkill*)pInvestigatorSkill->m_pSkill; strText = pSubSkill->m_pSkill->m_strName; strText += ": "; strText += pSubSkill->m_strName; if( pSubSkill->m_strName.GetLength() == 0 ) { SIZE sz; GetTextExtentPoint32( lpDrawItemStruct->hDC, LPCSTR(strText), strText.GetLength(), &sz ); RECT rc; rc.top = lpDrawItemStruct->rcItem.top + 5; rc.left = lpDrawItemStruct->rcItem.left + 8 + sz.cx; rc.right = lpDrawItemStruct->rcItem.right - 48; rc.bottom = lpDrawItemStruct->rcItem.bottom - 5; DrawFocusRect( lpDrawItemStruct->hDC, &rc ); } } else strText = pInvestigatorSkill->m_pSkill->m_strName; if( pInvestigatorSkill->m_pSkill->m_SkillType == ANYSKILL ) { RECT rc; rc.top = lpDrawItemStruct->rcItem.top + 5; rc.left = lpDrawItemStruct->rcItem.left + 4; rc.right = lpDrawItemStruct->rcItem.right - 48; rc.bottom = lpDrawItemStruct->rcItem.bottom - 5; DrawFocusRect( lpDrawItemStruct->hDC, &rc ); rc.top = lpDrawItemStruct->rcItem.top + 5; rc.left = lpDrawItemStruct->rcItem.right - 40; rc.right = lpDrawItemStruct->rcItem.right - 4; rc.bottom = lpDrawItemStruct->rcItem.bottom - 5; DrawFocusRect( lpDrawItemStruct->hDC, &rc ); strText = ""; } if( strText.GetLength() > 0 && strText[0] == '*' ) { const char * pszName = LPCSTR(strText); while( *pszName == '*' ) pszName++; CString strNewText = pszName; //draw the text, without a leading '*' TextOut( lpDrawItemStruct->hDC, 2+lpDrawItemStruct->rcItem.left, lpDrawItemStruct->rcItem.top + ((lpDrawItemStruct->rcItem.bottom - lpDrawItemStruct->rcItem.top) / 2 ) + 3, strNewText, strNewText.GetLength() ); } else //draw the text TextOut( lpDrawItemStruct->hDC, 2+lpDrawItemStruct->rcItem.left, lpDrawItemStruct->rcItem.top + ((lpDrawItemStruct->rcItem.bottom - lpDrawItemStruct->rcItem.top) / 2 ) + 3, LPCSTR(strText), strText.GetLength() ); //put the old font back again if( hFontOld ) DeleteObject( SelectObject( lpDrawItemStruct->hDC, hFontOld ) ); //draw the skill chance if( pInvestigatorSkill->m_pSkill->m_SkillType != ANYSKILL ) { strText.Format( "%d%%", pInvestigatorSkill->m_nCurrent ); SetTextAlign( lpDrawItemStruct->hDC, TA_LEFT|VTA_BASELINE ); TextOut( lpDrawItemStruct->hDC, lpDrawItemStruct->rcItem.right - 36, lpDrawItemStruct->rcItem.top + ((lpDrawItemStruct->rcItem.bottom - lpDrawItemStruct->rcItem.top) / 2 ) + 3, LPCSTR(strText), strText.GetLength() ); } } //draw the focus rectangle if( lpDrawItemStruct->itemState & ODS_FOCUS ) DrawFocusRect( lpDrawItemStruct->hDC, &lpDrawItemStruct->rcItem ); }
// // Create a wrapper for the default GUI font. // TDefaultGUIFont::TDefaultGUIFont() : TFont(HFONT(::GetStockObject(DEFAULT_GUI_FONT))) { }
// /// Handles WM_GETFONT. Returns font used by control if one was specified earlier. /// Otherwise, returns 0. // HFONT TUrlLink::EvGetFont() { PRECONDITION(!LinkFont || LinkFont->IsGDIObject()); return LinkFont ? HFONT(*LinkFont) : HFONT(0); }