Click here to Skip to main content
15,907,396 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Can Dialog have more than 256 controls??? Pin
Nish Nishant29-Jan-02 18:20
sitebuilderNish Nishant29-Jan-02 18:20 
AnswerRe: Can Dialog have more than 256 controls??? Pin
Not Active30-Jan-02 1:54
mentorNot Active30-Jan-02 1:54 
GeneralRe: Can Dialog have more than 256 controls??? Pin
Rüpel30-Jan-02 3:05
Rüpel30-Jan-02 3:05 
GeneralHelp on obtaining a pointer to my CDocument derived class Pin
VanHlebar29-Jan-02 16:40
VanHlebar29-Jan-02 16:40 
GeneralRe: Help on obtaining a pointer to my CDocument derived class Pin
Jens Kreiensiek29-Jan-02 21:09
Jens Kreiensiek29-Jan-02 21:09 
GeneralRe: Help on obtaining a pointer to my CDocument derived class Pin
VanHlebar30-Jan-02 1:47
VanHlebar30-Jan-02 1:47 
Questionhow to do a Custom draw CTreeCtrl Pin
zhangyifei29-Jan-02 14:59
zhangyifei29-Jan-02 14:59 
AnswerRe: how to do a Custom draw CTreeCtrl Pin
wangyiming30-Jan-02 0:12
wangyiming30-Jan-02 0:12 
these codes is part my project:

class CLvlIndexTree : public CTreeCtrl
{
public:
int m_nSplIndex;
...
};

void CLvlIndexTree::OnPaint()
{
CPaintDC dc(this); // device context for painting

CRect rcClip, rcClient;
dc.GetClipBox( &rcClip );
GetClientRect(&rcClient);

// Set clip region to be same as that in paint DC
CRgn rgn;
rgn.CreateRectRgnIndirect( &rcClip );
dc.SelectClipRgn(&rgn);
rgn.DeleteObject();

COLORREF m_wndColor = GetSysColor( COLOR_WINDOW );

dc.SetViewportOrg(0, 0);
dc.SetTextColor(m_wndColor);

// First let the control do its default drawing.
CWnd::DefWindowProc( WM_PAINT, (WPARAM)dc.m_hDC, 0 );

HTREEITEM hItem = GetFirstVisibleItem();
int n = GetVisibleCount();

// the most urgent thing is to erase the labels that were drawn by the tree
while(hItem!=NULL && n>=0)
{
CRect rect;
GetItemRect( hItem, &rect, TRUE );

dc.FillSolidRect(rect.left,rect.top,rect.Width(),rect.Height(),m_wndColor);
hItem = GetNextVisibleItem( hItem );
n--;
}

// create the font
CFont *pFontDC;
CFont fontDC, boldFontDC;
LOGFONT logfont;

CFont *pFont = GetFont();
pFont->GetLogFont( &logfont );

fontDC.CreateFontIndirect( &logfont );
pFontDC = dc.SelectObject( &fontDC );

logfont.lfWeight = 700;
boldFontDC.CreateFontIndirect( &logfont );

// and now let's get to the painting itself
UINT nDrawFormat = DT_CENTER;

BOOL bFoundSpl = FALSE;

hItem = GetFirstVisibleItem();
n = GetVisibleCount();
while(hItem!=NULL && n>=0)
{
CRect rect;

BOOL bBold = (GetParentItem( hItem ) == NULL);
BOOL bSplColor = FALSE;
if ( bBold && !bFoundSpl && m_nSplIndex >= 0 )
{
HTREEITEM hTmpItem = GetRootItem();
int index = 0;
while( hTmpItem != NULL )
{
if( index == m_nSplIndex && hTmpItem == hItem )
{
bFoundSpl = TRUE;
bSplColor = TRUE;
}
hTmpItem = GetNextSiblingItem(hTmpItem);
index++;
}
}

UINT selflag = TVIS_DROPHILITED | TVIS_SELECTED;

if ( !(GetItemState( hItem, selflag ) & selflag ))
{
dc.SetBkMode(TRANSPARENT);

CString text = GetItemText( hItem );
GetItemRect( hItem, &rect, TRUE );


dc.SetBkColor( m_wndColor );
dc.SetTextColor( bSplColor ? RGB(255,0,0) : RGB(0,0,0) );

if( bBold )
dc.SelectObject( &boldFontDC );

dc.DrawText(text, rect, nDrawFormat);

if( bBold )
dc.SelectObject( &fontDC );
dc.SetTextColor(::GetSysColor (COLOR_WINDOWTEXT ));
}
else
{
GetItemRect( hItem, &rect, TRUE );

COLORREF m_highlightColor = ::GetSysColor (COLOR_HIGHLIGHT);
CBrush brush(m_highlightColor);

dc.FillRect (rect, &brush);

// draw a dotted focus rectangle
dc.DrawFocusRect (rect);

CString text = GetItemText( hItem );

dc.SetBkColor(m_highlightColor);
dc.SetTextColor(::GetSysColor (COLOR_HIGHLIGHTTEXT));

if( bBold )
dc.SelectObject( &boldFontDC );

dc.DrawText(text, rect, nDrawFormat);

if( bBold )
dc.SelectObject( &fontDC );
}

hItem = GetNextVisibleItem( hItem );
n--;
}

dc.SelectObject( pFontDC );
}

GeneralTemplate collection classes in VC++7 Pin
paulb29-Jan-02 13:32
paulb29-Jan-02 13:32 
GeneralRe: Template collection classes in VC++7 Pin
Joaquín M López Muñoz29-Jan-02 20:01
Joaquín M López Muñoz29-Jan-02 20:01 
QuestionHow to grab system icons Pin
Aaron Schaefer29-Jan-02 12:44
Aaron Schaefer29-Jan-02 12:44 
AnswerRe: How to grab system icons Pin
Joaquín M López Muñoz29-Jan-02 13:15
Joaquín M López Muñoz29-Jan-02 13:15 
GeneralRe: How to grab system icons Pin
Christopher Lord29-Jan-02 13:21
Christopher Lord29-Jan-02 13:21 
Generalnewbie question about staticly linked exe's Pin
RobJones29-Jan-02 12:04
RobJones29-Jan-02 12:04 
GeneralRe: newbie question about staticly linked exe's Pin
Ravi Bhavnani29-Jan-02 12:20
professionalRavi Bhavnani29-Jan-02 12:20 
GeneralRe: newbie question about staticly linked exe's Pin
Simon Walton29-Jan-02 12:20
Simon Walton29-Jan-02 12:20 
GeneralRe: newbie question about staticly linked exe's Pin
Tim Smith29-Jan-02 12:20
Tim Smith29-Jan-02 12:20 
GeneralRe: newbie question about staticly linked exe's Pin
Joaquín M López Muñoz29-Jan-02 12:27
Joaquín M López Muñoz29-Jan-02 12:27 
GeneralDamned ActiveX control Pin
29-Jan-02 11:14
suss29-Jan-02 11:14 
GeneralRe: Damned ActiveX control Pin
Joaquín M López Muñoz29-Jan-02 12:52
Joaquín M López Muñoz29-Jan-02 12:52 
GeneralCopyImage with NT/W2K Pin
PJ Arends29-Jan-02 10:28
professionalPJ Arends29-Jan-02 10:28 
GeneralWinsock problem!! Pin
Rickard Andersson2029-Jan-02 10:01
Rickard Andersson2029-Jan-02 10:01 
GeneralRe: Winsock problem!! Pin
Joaquín M López Muñoz29-Jan-02 10:32
Joaquín M López Muñoz29-Jan-02 10:32 
GeneralRe: Winsock problem!! Pin
Nish Nishant29-Jan-02 20:19
sitebuilderNish Nishant29-Jan-02 20:19 
GeneralRe: Winsock problem!! Pin
Rickard Andersson2029-Jan-02 21:41
Rickard Andersson2029-Jan-02 21:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.