Click here to Skip to main content
15,893,663 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalunace.dll Pin
carrie17-May-02 13:11
carrie17-May-02 13:11 
GeneralRe: unace.dll Pin
Mukkie18-May-02 0:38
Mukkie18-May-02 0:38 
Generalsimple question Pin
rbc17-May-02 12:50
rbc17-May-02 12:50 
GeneralRe: simple question Pin
Jack Handy17-May-02 13:34
Jack Handy17-May-02 13:34 
GeneralRe: simple question Pin
rbc17-May-02 14:00
rbc17-May-02 14:00 
GeneralRe: simple question Pin
rbc17-May-02 14:09
rbc17-May-02 14:09 
GeneralUDP broadcast again!! Pin
Rickard Andersson2017-May-02 12:34
Rickard Andersson2017-May-02 12:34 
GeneralCListView.. OnPaint().. Help! Pin
RobJones17-May-02 11:33
RobJones17-May-02 11:33 
I have been working on double buffering my CListView for the past few days... After this bit of code below, my list is now flicker free. The only problem I am having is that my Header wasn't being drawn.. When I add my code to draw the Header my items are shifted down for example.. when I add a item to row 1 its drawn in row 2 (row 1 appears empty) so if you click the mouse on the empty row 1 it highlights row 2, and so on.. if I exclude the code for the Header all the items are drawn correctly.

Any ideas on what I am doing wrong?

void CMyListView::OnPaint() 
{
	CRect  rc;
	CRect rcWnd;
	CRect rcH;
	CPaintDC dc(this);
	CDC     MemoryDC;
	CBitmap Bitmap;
	CBrush  Brush;
	
	GetParent()->GetClientRect(&rc);
	if (rc.Size() == CSize(0,0))
		return;
	
	GetParent()->GetWindowRect(&rcWnd);

	//If there is a header, we need to account for the space it occupies
	CHeaderCtrl* pHC = (CHeaderCtrl*)(GetListCtrl().GetDlgItem(0));
	
	if(pHC != NULL)
	{
		pHC->GetItemRect(0,&rcH);
		rc.top += rcH.bottom;
	}
	
	int rcWndW = rcWnd.Width(), rcWndH = rcWnd.Height();
	TRACE("%d %d", rcWndW, rcWndH);

	// Paint to a compatible DC
	MemoryDC.CreateCompatibleDC(&dc);
	Bitmap.CreateCompatibleBitmap(&dc, rcWndW, rcWndH);
	CBitmap *pOldBitmap = MemoryDC.SelectObject(&Bitmap);
	
	// Fill background (does what WM_ERASEBKGND would do)
	Brush.CreateSolidBrush(dc.GetBkColor());
	MemoryDC.FillRect(&CRect(0,0, rcWndW,rcWndH), &Brush);
	
	// Do client first then the rest otherwise system
	// scrollbars don't draw correctly.
	Print(&MemoryDC, PRF_CLIENT);
	Print(&MemoryDC,PRF_OWNED);

	// Offset the MemoryDC drawing rectangle by rcBounds 
	CRect rcDraw = rc - rc.TopLeft();

	// Dump bits to real device context.
	dc.BitBlt(rc.left,rc.top, rc.Width(),rc.Height(), &MemoryDC, rcDraw.left,rcDraw.top, SRCCOPY);
	
	MemoryDC.SelectObject(pOldBitmap);
}

GeneralRe: CListView.. OnPaint().. Help! Pin
Shog917-May-02 14:30
sitebuilderShog917-May-02 14:30 
GeneralSame problem :( Pin
17-May-02 14:42
suss17-May-02 14:42 
GeneralRe: Same problem :( Pin
Shog917-May-02 15:52
sitebuilderShog917-May-02 15:52 
GeneralThanks! Pin
RobJones20-May-02 6:18
RobJones20-May-02 6:18 
GeneralMAPIAddress() and the default button Pin
Shog917-May-02 11:23
sitebuilderShog917-May-02 11:23 
GeneralCTreeCtrl issues Pin
dazinith17-May-02 10:33
dazinith17-May-02 10:33 
GeneralRe: CTreeCtrl issues Pin
Ravi Bhavnani17-May-02 11:06
professionalRavi Bhavnani17-May-02 11:06 
GeneralRe: CTreeCtrl issues Pin
dazinith20-May-02 3:59
dazinith20-May-02 3:59 
GeneralProblems with MNEMONICS !! Pin
Cris17-May-02 10:25
Cris17-May-02 10:25 
GeneralRe: Problems with MNEMONICS !! Pin
Ravi Bhavnani17-May-02 11:07
professionalRavi Bhavnani17-May-02 11:07 
GeneralRe: Problems with MNEMONICS !! Pin
Cris20-May-02 2:18
Cris20-May-02 2:18 
QuestionQT, anyone? Pin
Ravi Bhavnani17-May-02 9:45
professionalRavi Bhavnani17-May-02 9:45 
QuestionSetting an environment variable? Pin
Jamie Hale17-May-02 9:22
Jamie Hale17-May-02 9:22 
AnswerRe: Setting an environment variable? Pin
Jamie Hale17-May-02 9:25
Jamie Hale17-May-02 9:25 
GeneralStatus Bar height Pin
Stan the man17-May-02 8:38
Stan the man17-May-02 8:38 
GeneralRe: Status Bar height Pin
Mike.NET17-May-02 9:04
Mike.NET17-May-02 9:04 
QuestionHow to write for 32 bit color in VC++? Pin
17-May-02 8:25
suss17-May-02 8:25 

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.