本文整理汇总了C++中TDC::SetBkColor方法的典型用法代码示例。如果您正苦于以下问题:C++ TDC::SetBkColor方法的具体用法?C++ TDC::SetBkColor怎么用?C++ TDC::SetBkColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TDC
的用法示例。
在下文中一共展示了TDC::SetBkColor方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawDisabledButton
void DrawDisabledButton(TDC& dc, const TRect& rc)
{
// create a monochrome memory DC
//
TMemoryDC ddc;
TBitmap bmp(ddc, rc.Width(), rc.Height());
ddc.SelectObject(bmp);
// build a mask
//
ddc.PatBlt(0, 0, rc.Width(), rc.Height(), WHITENESS);
dc.SetBkColor(TColor::Sys3dFace);
ddc.BitBlt(0, 0, rc.Width(), rc.Height(), dc, rc.left, rc.top, SRCCOPY);
dc.SetBkColor(TColor::Sys3dHilight);
ddc.BitBlt(0, 0, rc.Width(), rc.Height(), dc, rc.left, rc.top, SRCPAINT);
// Copy the image from the toolbar into the memory DC
// and draw it (grayed) back into the toolbar.
//
dc.FillRect(rc, TBrush(TColor::Sys3dFace));
dc.SetBkColor(RGB(0, 0, 0));
dc.SetTextColor(RGB(255, 255, 255));
TBrush brShadow(TColor::Sys3dShadow);
TBrush brHilight(TColor::Sys3dHilight);
dc.SelectObject(brHilight);
dc.BitBlt(rc.left+1, rc.top+1, rc.Width(), rc.Height(), ddc, 0, 0, 0x00E20746L);
dc.SelectObject(brShadow);
dc.BitBlt(rc.left, rc.top, rc.Width(), rc.Height(), ddc, 0, 0, 0x00E20746L);
// reset DCs
//
dc.RestoreBrush();
dc.RestoreBrush();
ddc.RestoreBitmap();
}
示例2: rect
// MFC style function, that draws a filled rect. Is this faster???
void
FillSolidRect(TDC& dc, int x, int y, int cx, int cy, TColor clr)
{
TColor oldColor = dc.SetBkColor(clr);
TRect rect(x, y, x + cx, y + cy);
dc.ExtTextOut(0, 0, ETO_OPAQUE, &rect, _T(""), 0, 0);
dc.SetBkColor(oldColor);
}
示例3: face
//
/// Paint the text gadget by painting gadget borders, & then painting text in
/// the InnerRect. Empty or 0 text blanks the gadget.
//
/// Calls TGadget::PaintBorder to paint the border. Calls TGadget::GetInnerRect to
/// calculate the area of the text gadget's rectangle. If the text is left-aligned,
/// Paint calls dc.GetTextExtent to compute the width and height of a line of the
/// text. To set the background color, Paint calls dc.GetSysColor and sets the
/// default background color to face shading (COLOR_BTNFACE). To set the button text
/// color, Paint calls dc.SetTextColor and sets the default button text color to
/// COLOR_BTNTEXT. To draw the text, Paint calls dc.ExtTextOut and passes the
/// parameters ETO_CLIPPED (so the text is clipped to fit the rectangle) and
/// ETO_OPAQUE (so the rectangle is filled with the current background color).
//
void
TTextGadget::Paint(TDC& dc)
{
PaintBorder(dc);
TRect innerRect;
GetInnerRect(innerRect);
if (!Font)
dc.SelectObject(GetGadgetWindow()->GetFont());
else
dc.SelectObject(*Font);
TColor textColor = GetEnabledColor();
if(!GetEnabled())
textColor = TColor::Sys3dHilight;
bool transparent = GetGadgetWindow()->GetFlatStyle() & TGadgetWindow::FlatXPTheme;
if(!Text){
if (!transparent)
{
TColor color = dc.SetBkColor(TColor::Sys3dFace);
dc.ExtTextOut(0,0, ETO_OPAQUE, &innerRect, _T(""), 0);
dc.SetBkColor(color);
}
}
else
{
// Create a UI Face object for this button & let it paint the button face
//
uint align[] = {DT_LEFT, DT_CENTER, DT_RIGHT};
uint format = DT_SINGLELINE | DT_VCENTER | align[Align];
TUIFace face(innerRect, Text, BkgndColor, format);
TPoint dstPt(innerRect.TopLeft());
dc.SetBkColor(BkgndColor);
TColor oldTxColor = dc.SetTextColor(textColor);
if (!GetEnabled())
face.Paint(dc, dstPt, TUIFace::Disabled, false, !transparent);
else
face.Paint(dc, dstPt, TUIFace::Normal, false, !transparent);
dc.SetTextColor(oldTxColor);
}
dc.RestoreFont();
}
示例4: GetClientRect
//
/// Adjusts the message bar and paints a highlight line. Then, PaintGadgets either
/// paints the hint text if any is set or calls TGadgetWindow::PaintGadgets to
/// repaint each gadget.
//
void
TMessageBar::PaintGadgets(TDC& dc, bool erase, TRect& rect)
{
if (HighlightLine && rect.top == 0)
dc.TextRect(0, 0, rect.right, TUIMetric::CyBorder, TColor::Sys3dHilight);
if (!HintText.empty())
{
TRect clientRect = GetClientRect();
int y = (clientRect.bottom - GetFontHeight()) / 2;
if (HighlightLine)
clientRect.top += TUIMetric::CyBorder;
dc.SelectObject(GetFont());
dc.SetBkColor(TColor::Sys3dFace);
dc.ExtTextOut(5, y, ETO_OPAQUE, &clientRect, HintText, static_cast<int>(HintText.length()));
}
else
{
TGadgetWindow::PaintGadgets(dc, erase, rect);
}
}
示例5: mdc
////////////////////////////////////////////////////////////
// TBitmap256Control
// -----------------
// Display bitmap in DC
void TBitmap256Control::DisplayBitmap (TDC& dc, TRect &rect)
{
// Display a cross if no bitmap
if ( pDIBInfo == 0 )
{
dc.SelectObject(TPen(TColor::LtGray));
dc.MoveTo (0, 0);
dc.LineTo (MaxWidth, MaxHeight);
dc.MoveTo (0, MaxHeight);
dc.LineTo (MaxWidth, 0);
dc.SetTextAlign(TA_CENTER);
dc.SetTextColor(TColor::White);
dc.SetBkColor(TColor::Black);
char tmp[40];
if ( BitmapName[0] != '\0' && BitmapName[0] != '-' )
wsprintf (tmp, "No picture (%s)", BitmapName);
else
wsprintf (tmp, "No picture");
dc.TextOut (MaxWidth / 2, MaxHeight / 2 - 6, tmp);
return;
}
assert (pBitmapPalette != NULL);
// pBitmapPalette->UnrealizeObject();
dc.SelectObject (*pBitmapPalette);
dc.RealizePalette();
dc.SetStretchBltMode (COLORONCOLOR);
#if 1
TRect ZoomRect;
ZoomRect.left = rect.left;
ZoomRect.top = rect.top;
ZoomRect.right = rect.right;
ZoomRect.bottom = rect.bottom;
// Convert the rect. size to a rect in the sprite
rect.left /= ZoomFactor;
rect.top /= ZoomFactor;
rect.right /= ZoomFactor;
rect.bottom /= ZoomFactor;
TRect DIBRect;
DIBRect.left = rect.left;
DIBRect.top = BitmapYSize - rect.bottom; // DIBs are Y inversed
DIBRect.right = DIBRect.left + rect.Width();
DIBRect.bottom = DIBRect.top + rect.Height();
dc.StretchDIBits (ZoomRect,
DIBRect,
pDIBits, *pDIBInfo,
DIB_PAL_COLORS, SRCCOPY);
#else
// Create memory DC and display bitmap
TMemoryDC mdc (dc);
mdc.SelectObject (*pBitmapPalette);
mdc.SelectObject (*pBitmap);
dc.StretchBlt(0, 0, ZoomXSize, ZoomYSize,
mdc,
0, 0, BitmapXSize, BitmapYSize,
SRCCOPY);
// Restore GDI objects
mdc.RestoreBitmap();
mdc.RestorePalette();
#endif
dc.RestorePalette();
}
示例6: Paint
void npredictMDIChild::Paint ( TDC& dc , BOOL , TRect& )
{
int i, j, n, b, row, col, rstart, rstop, cstart, cstop, prevcol ;
int xlab_height, xlab_width, ylab_height, ylab_width, wide ;
int xlab_lw, xlab_rw, tick_height, font_height, r0, r1, c0 ;
double xscale, yscale, xtickscale, ytickscale, *sig, val ;
double x, xfac ;
char msg[256] ;
TRect rect ;
SIZE size ;
TColor bkgnd, *lines ;
TBrush *brush ;
TPen *pen, *second_pen ;
TFont *font ;
n = istop - istart + 1 ;
sig = signal->sig ;
dc.SetMapMode ( MM_TEXT ) ;
dc.SetROP2 ( R2_COPYPEN ) ;
dc.SetBkMode ( OPAQUE ) ;
bkgnd = dc.GetNearestColor ( TColor ( background_color ) ) ;
dc.SetBkColor ( bkgnd ) ;
GetClientRect ( rect ) ;
b = rect.bottom ; // We use origin at bottom, so b-y adapts to Windows
/*
Paint the background
*/
brush = new TBrush ( bkgnd ) ;
dc.SelectObject ( *brush ) ;
pen = new TPen ( bkgnd ) ;
dc.SelectObject ( *pen ) ;
dc.Rectangle ( rect ) ;
dc.RestoreBrush () ;
delete brush ;
dc.RestorePen () ;
delete pen ;
/*
Setup main drawing pen and secondary pen for hash lines
*/
lines = new TColor ( 0 , 0 , 0 ) ;
pen = new TPen ( *lines , 1 , PS_SOLID ) ;
second_pen = new TPen ( *lines , 1 , PS_DASH ) ;
/*
Compute the maximum height and width of the axis tick labels.
This lets us position the graph optimally.
*/
xlab_height = xlab_width = ylab_height = ylab_width = xlab_lw = xlab_rw = 0 ;
font_height = rect.bottom / 20 ;
if (rect.right / 24 < font_height)
font_height = rect.right / 24 ;
if (font_height < 8)
font_height = 0 ;
if (font_height) {
font = new TFont ( "Helvetica" , font_height ) ;
dc.SelectObject ( *font ) ;
for (i=0 ; i<xnticks ; i++) {
sprintf ( msg , "%*.*lf", xndigits, xnfrac, xmin + i * xdif ) ;
GetTextExtentPoint ( dc , msg , strlen(msg) , &size ) ;
if (! i)
xlab_lw = size.cx ; // Width of leftmost x label
if (i == xnticks-1)
xlab_rw = size.cx ; // And rightmost x label
if (size.cx > xlab_width)
xlab_width = size.cx ;
if (size.cy > xlab_height)
xlab_height = size.cy ;
}
for (i=0 ; i<ynticks ; i++) {
sprintf ( msg , "%*.*lf", yndigits, ynfrac, ymin + i * ydif ) ;
GetTextExtentPoint ( dc , msg , strlen(msg) , &size ) ;
if (size.cx > ylab_width)
ylab_width = size.cx ;
if (size.cy > ylab_height)
ylab_height = size.cy ;
}
tick_height = xlab_height / 2 ;
}
else {
tick_height = rect.bottom / 64 + 2 ;
font = NULL ;
}
/*
Last check on label display. Are X-axis labels to wide?
*/
if ((xlab_width * xnticks) > (3 * rect.right / 4)) {
//.........这里部分代码省略.........