本文整理汇总了C++中TDC::SetBkMode方法的典型用法代码示例。如果您正苦于以下问题:C++ TDC::SetBkMode方法的具体用法?C++ TDC::SetBkMode怎么用?C++ TDC::SetBkMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TDC
的用法示例。
在下文中一共展示了TDC::SetBkMode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//
/// 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();
}
示例2: Paint
/////////////////////////////////////////////////////////////////////
// TInfoControl
// ------------
//
void TInfoControl::Paint (TDC& dc, BOOL erase, TRect& rect)
{
TControl::Paint(dc, erase, rect);
TRect cRect = GetClientRect();
// Select font
dc.SelectObject (*StaticFont);
dc.SetBkMode (TRANSPARENT);
// Draw each text line
if ( TextLineTab != NULL )
{
for (int i = 0 ; i < NumLines ; i++)
{
if (TextLineTab[i] != NULL && TextLineTab[i]->Text != NULL)
{
int x;
dc.SetTextColor ( TMapDC::GetColor16(TextLineTab[i]->Color));
dc.SetTextAlign( TextLineTab[i]->Align);
switch (TextLineTab[i]->Align & (TA_CENTER |TA_LEFT |TA_RIGHT))
{
case TA_LEFT:
x = 0;
break;
case TA_CENTER:
x = cRect.Width() / 2;
break;
case TA_RIGHT:
x = cRect.Width() - 1;
break;
}
dc.TextOut( x, FontHeight * i, TextLineTab[i]->Text);
}
}
}
dc.RestoreFont();
}
示例3: 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)) {
//.........这里部分代码省略.........