void CXTPCoreTreeControl::OnPaint() { CPaintDC dcPaint(this); // device context for painting CRect rcPaint(dcPaint.m_ps.rcPaint); CXTPBufferDC dc(dcPaint); OnDraw(&dc, rcPaint); }
HBRUSH CXTPSkinObjectFrame::GetClientBrush(HDC hDC, HWND hWnd, UINT nCtlColor) { if (m_dwDialogTexture != ETDT_ENABLETAB) { GrayCtlColor(hDC, hWnd, nCtlColor, GetMetrics()->m_brushDialog, GetColor(COLOR_BTNTEXT)); return GetMetrics()->m_brushDialog; } if (GetMetrics()->m_brushTabControl == NULL) { CWindowDC dcWindow(this); CXTPSkinManagerClass* pClass = GetSkinManager()->GetSkinClass(this, _T("TAB")); CString strImageFile = pClass->GetThemeString(TABP_BODY, 0, TMT_STOCKIMAGEFILE); if (strImageFile.IsEmpty()) { return GetMetrics()->m_brushDialog; } CXTPSkinImage* pImage = pClass->GetImages()->LoadFile(m_pManager->GetResourceFile(), strImageFile); if (!pImage) { return GetMetrics()->m_brushDialog; } CRect rc(0, 0, pImage->GetWidth(), pImage->GetHeight()); CBitmap bmp; bmp.CreateCompatibleBitmap(&dcWindow, rc.Width(), rc.Height()); CXTPCompatibleDC dc(&dcWindow, bmp); pImage->DrawImage(&dc, rc, rc, CRect(0, 0, 0, 0), COLORREF_NULL, ST_TRUESIZE, FALSE); GetMetrics()->m_brushTabControl = ::CreatePatternBrush(bmp); } if (hWnd != m_hWnd) { CXTPWindowRect rcPaint(hWnd); CXTPWindowRect rcBrush(m_hWnd); ::SetBrushOrgEx(hDC, rcBrush.left - rcPaint.left, rcBrush.top - rcPaint.top, NULL); ::SetBkMode(hDC, TRANSPARENT); ::SetTextColor(hDC, GetColor(COLOR_BTNTEXT)); } return GetMetrics()->m_brushTabControl; }
BOOL CUIDesignerView::SaveSkinImage(LPCTSTR pstrPathName) { CImage image; CWindowUI* pForm = m_LayoutManager.GetForm(); ASSERT(pForm); CSize szForm = pForm->GetInitSize(); CRect rcPaint(0,0,szForm.cx,szForm.cy); image.Create(szForm.cx, szForm.cy, 32); pForm->DoPaint(image.GetDC(), rcPaint); BOOL bRet = image.Save(pstrPathName, Gdiplus::ImageFormatJPEG); image.ReleaseDC(); return bRet; }
HBRUSH CXTPPropertyPage::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { if ((nCtlColor == CTLCOLOR_BTN || nCtlColor == CTLCOLOR_DLG || nCtlColor == CTLCOLOR_STATIC ) && m_pSheet) { HBRUSH hBrush = m_pSheet->GetNavigator()->GetPageBrush(pDC, this); if (hBrush) { CXTPWindowRect rcPaint(pWnd); CXTPWindowRect rcBrush(m_hWnd); ::SetBrushOrgEx(pDC->GetSafeHdc(), rcBrush.left - rcPaint.left, rcBrush.top - rcPaint.top, NULL); ::SetBkMode(pDC->GetSafeHdc(), TRANSPARENT); ::SetTextColor(pDC->GetSafeHdc(), GetSysColor(COLOR_BTNTEXT)); return hBrush; } } return CPropertyPage::OnCtlColor(pDC, pWnd, nCtlColor); }
void CTextCtrl::OnPaint() { CRect rcClient; GetClientRect( &rcClient ); CQuickLock pLock( m_pSection ); CPaintDC dc( this ); CFont* pOldFont = (CFont*)dc.SelectObject( &m_pFont ); if ( ! m_nHeight ) { CSize size = dc.GetTextExtent( _T("X") ); m_nHeight = size.cy += LINE_GAP; } const int nWidth = rcClient.right - OFFSET; BOOL bBottom = ( m_nPosition >= m_nTotal ); BOOL bModified = m_bProcess; if ( m_bProcess ) m_nTotal = 0; for ( int nLine = 0 ; nLine < m_pLines.GetSize() ; nLine++ ) { CTextLine* pLine = m_pLines.GetAt( nLine ); if ( m_bProcess || ! pLine->m_nLine ) { m_nTotal += pLine->Process( &dc, nWidth ); bModified = TRUE; } } if ( bBottom ) m_nPosition = m_nTotal; if ( bModified ) UpdateScroll( TRUE ); m_bProcess = FALSE; CRect rcLine( rcClient ); rcLine.bottom += ( m_nTotal - m_nPosition ) * m_nHeight; rcLine.top = rcLine.bottom - m_nHeight; // Note: Consider multi-line wrap and gap elsewhere dc.SetBkMode( OPAQUE ); for ( INT_PTR nLine = m_pLines.GetSize() - 1 ; nLine >= 0 && rcLine.bottom > 0 ; nLine-- ) { CTextLine* pLine = m_pLines.GetAt( nLine ); if ( pLine->m_bSelected && Images.m_bmSelected.m_hObject ) // Skinned { CRect rcPaint( rcLine ); rcPaint.bottom++; // Set wider for highlight if ( pLine->m_nLine > 1 ) rcPaint.top -= ( pLine->m_nLine - 1 ) * m_nHeight; dc.SetBkMode( TRANSPARENT ); CoolInterface.DrawWatermark( &dc, &rcPaint, &Images.m_bmSelected, FALSE ); // No overdraw WORD nType = pLine->m_nType & MSG_SEVERITY_MASK; dc.SetTextColor( nType > 2 ? Colors.m_crHighlight : m_crText[ nType ] ); pLine->Paint( &dc, &rcLine, TRUE ); dc.SetBkMode( OPAQUE ); } else // Default { dc.SetTextColor( pLine->m_bSelected ? Colors.m_crHiText : m_crText[ pLine->m_nType & MSG_SEVERITY_MASK ] ); dc.SetBkColor( pLine->m_bSelected ? Colors.m_crHighlight : Colors.m_crWindow ); // ToDo: Fix m_crBackground[ ( pLine->m_nType & MSG_FACILITY_MASK ) >> 8 ] pLine->Paint( &dc, &rcLine ); } } if ( rcLine.bottom > 0 ) { rcLine.top = 0; dc.FillSolidRect( &rcLine, Colors.m_crWindow ); // m_crBackground[ 0 ] } dc.SelectObject( pOldFont ); }
LONG FAR PASCAL SubClassFunc( HWND hwnd, WORD msg, WORD wParam, LONG lParam ) { switch( msg ) { case WM_CREATE: { Property *pProp = new Property; pProp->m_defaults.m_rcMargins.Set( 2, 2, 5, 5 ); SetProp( hwnd, g_pcszProperty, reinterpret_cast<HANDLE>( pProp ) ); } break; case WM_DESTROY: { Property *pProp = reinterpret_cast<Property *>( RemoveProp( hwnd, g_pcszProperty ) ); delete pProp; } break; case WM_WINDOWPOSCHANGING: { WINDOWPOS &pos = *(WINDOWPOS *)lParam; Property *pProp = reinterpret_cast<Property *>( GetProp( hwnd, g_pcszProperty ) ); if( !(pos.flags & SWP_NOSIZE) && !( pos.flags & SWP_NOMOVE ) && pProp ) { CWindowText text( hwnd ); if( text.GetLength() ) { HFONT hFont = (HFONT)SendMessage( hwnd, WM_GETFONT, 0, 0 ); pProp->m_defaults.SetFont( hFont ); pProp->m_sectHTML.SetHTML( text, text.GetLength(), NULL ); } return 0; } } break; case WM_WINDOWPOSCHANGED: { static bool bDealingWithIt = false; Property *pProp = reinterpret_cast<Property *>( GetProp( hwnd, g_pcszProperty ) ); if( pProp && !bDealingWithIt ) { bDealingWithIt = true; CRect rcTip( 0, 0, 300, 5 ); CDrawContext dc; pProp->m_sectHTML.OnLayout( rcTip, dc ); const CSize size( pProp->m_sectHTML.GetSize() ); rcTip.SetSize( size ); pProp->m_sectHTML.bottom = size.cy; pProp->m_sectHTML.right = size.cx; CPoint ptCursor; GetCursorPos( ptCursor ); ptCursor.x += g_knTipClearanceX; ptCursor.y += g_knTipClearanceY; rcTip.Offset( ptCursor.x, ptCursor.y ); CRect rcDesktop; GetDisplayWorkArea( hwnd, rcDesktop ); if( rcTip.right >= rcDesktop.right ) { rcTip.Offset( -(rcTip.right - rcDesktop.right) - g_knTipClearanceX, 0 ); } if( rcTip.bottom >= rcDesktop.bottom ) { rcTip.Offset( 0, -rcTip.Height() - g_knTipClearanceY ); } SetWindowPos( hwnd, NULL, rcTip.left, rcTip.top, rcTip.Width(), rcTip.Height(), SWP_NOACTIVATE | SWP_NOSENDCHANGING | SWP_NOZORDER ); bDealingWithIt = false; } return 0; } case WM_PAINT: { Property *pProp = reinterpret_cast<Property *>( GetProp( hwnd, g_pcszProperty ) ); if( pProp ) { PAINTSTRUCT ps; BeginPaint( hwnd, &ps ); CRect rcPaint( ps.rcPaint ); if( rcPaint.IsEmpty() ) { GetClientRect( hwnd, &rcPaint ); } // // Scoped to allow the draw context to go out of scope before EndPaint is called. { CDrawContext dc( &rcPaint, ps.hdc ); SelectPalette( ps.hdc, GetCurrentWindowsPalette(), TRUE ); RealizePalette( ps.hdc ); pProp->m_sectHTML.OnDraw( dc ); } EndPaint( hwnd, &ps ); return 0; } break; } } return CallWindowProc( g_lpfnOldWndProc, hwnd, msg, wParam, lParam); }