Click here to Skip to main content
15,900,816 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Visual Basic sendmessage Pin
David Crow26-May-04 2:13
David Crow26-May-04 2:13 
GeneralRe: Visual Basic sendmessage Pin
soul.ripper29-May-04 7:29
soul.ripper29-May-04 7:29 
GeneralRe: Visual Basic sendmessage Pin
David Crow31-May-04 9:22
David Crow31-May-04 9:22 
GeneralactiveX control - using CListCtrl Pin
BlackDice24-May-04 10:44
BlackDice24-May-04 10:44 
GeneralRe: activeX control - using CListCtrl Pin
Dimitris Vasiliadis24-May-04 12:05
Dimitris Vasiliadis24-May-04 12:05 
GeneralRe: activeX control - using CListCtrl Pin
BlackDice25-May-04 6:00
BlackDice25-May-04 6:00 
GeneralGetSaveFileNamePreview Pin
Andy Moore24-May-04 9:44
Andy Moore24-May-04 9:44 
GeneralDouble buffering with GDI+ Pin
Jorgen E.24-May-04 8:49
Jorgen E.24-May-04 8:49 
Hi,

I'm trying to implement double buffering in my MFC application, but keep running into a (to me) strange problem. I've read through the article "drawing speed in GDI+", and been trying to follow the code from step 2 in this article. My code (see below) compiles, but when I execute my app, I get the "standard" windows dialog, which asks if I want to send an error report, and forces me to terminate the application.

Please remember that I'm a newbie, there are certanly much bad code below, I'm just asking for the errorLaugh | :laugh: ...

My view is derived frow CScrollView. Does this have anything to do with anything?


<br />
	// Kode for å tegne opp rapporten<br />
<br />
	// Beregner området å tegne i<br />
	CRect rect;<br />
	GetClientRect(&rect);<br />
	int nWidth = rect.right - rect.left +1;<br />
	int nHeight = rect.bottom - rect.top + 1;<br />
<br />
	CClientDC ClientDC(this);<br />
	Graphics graphics(ClientDC.m_hDC);	// GDI+ Stuff graph(ClientDC.m_hDC);<br />
<br />
	// Test for drawing with double buffering<br />
        // Bitmap* bmp = new Bitmap(nWidth,nHeight); and<br />
        // Bitmap* bmp(nWidth,nHeight); seems to give the same results...<br />
	#ifdef _DEBUG<br />
	#undef new<br />
		Bitmap* bmp = new Bitmap(nWidth,nHeight);<br />
	#define new DEBUG_NEW<br />
	#else<br />
		Bitmap* bmp = new Bitmap(nWidth,nHeight);<br />
	#endif<br />
		Graphics* graph = Graphics::FromImage(bmp);<br />
	<br />
	CRect area( 0, 0, 0, 0);<br />
<br />
        // This works, no questions asked, but it's not double buffering<br />
	area.SetRect( 8, 90, 814, 90); // Skillelinje som skiller elevdata fra resten av skjemaet<br />
	DrawLine(&graphics, area, 1);<br />
<br />
	/*       Test drawing to test double buffering */<br />
	// Takes about 10 seconds without double buffering<br />
	// Takes about xx seconds with double buffering<br />
	Pen pen(Color(200,0,0, 50));<br />
	for( int j=100; j<500;j = j + 5) {<br />
		for (int i=100; i<500; i = i + 5) {<br />
			area.SetRect( 110,110, j, i);<br />
<br />
                        // This works.<br />
			DrawLine(&graphics, area, 1);<br />
<br />
                        // This line causes the crach, when commented out, the code does what it's supposed to do<br />
			// graph->DrawLine(&pen, area.left, area.top, area.Width(), area.Height());<br />
		}<br />
	}<br />
<br />
	graphics.DrawImage( bmp, 0,0, 600, 600);<br />
	delete graph;<br />
	delete bmp;<br />
	/*       End test drawing       */<br />


This is my version of DrawLine Smile | :)

<br />
void CITPAXpertView::DrawLine(Graphics *pdc, CRect rect, int width)<br />
{<br />
	// Beregner hvor vi er "i landskapet" når det gjelder scrolling<br />
	CPoint where = GetDeviceScrollPosition();<br />
<br />
	// Lager en penn å tegne med<br />
	Pen penn(Color(0,0,0), REAL(width));<br />
<br />
	// Takes care of drawing lines<br />
	pdc->DrawLine( &penn, rect.left - where.x, rect.top - where.y, rect.right - where.x, rect.bottom - where.y);<br />
}<br />

GeneralRe: Double buffering with GDI+ Pin
567890123424-May-04 19:28
567890123424-May-04 19:28 
GeneralRe: Double buffering with GDI+ Pin
Jorgen E.25-May-04 3:30
Jorgen E.25-May-04 3:30 
GeneralRe: Double buffering with GDI+ Pin
567890123425-May-04 4:06
567890123425-May-04 4:06 
GeneralRe: Double buffering with GDI+ Pin
Jorgen E.25-May-04 4:45
Jorgen E.25-May-04 4:45 
GeneralRe: Double buffering with GDI+ Pin
567890123425-May-04 5:05
567890123425-May-04 5:05 
GeneralRe: Double buffering with GDI+ Pin
Jorgen E.25-May-04 5:12
Jorgen E.25-May-04 5:12 
GeneralRe: Double buffering with GDI+ Pin
567890123425-May-04 5:17
567890123425-May-04 5:17 
GeneralRe: Double buffering with GDI+ Pin
Jorgen E.25-May-04 5:22
Jorgen E.25-May-04 5:22 
GeneralRe: Double buffering with GDI+ Pin
567890123425-May-04 5:43
567890123425-May-04 5:43 
GeneralRe: Double buffering with GDI+ Pin
Jorgen E.25-May-04 6:01
Jorgen E.25-May-04 6:01 
GeneralRe: Double buffering with GDI+ Pin
567890123425-May-04 6:46
567890123425-May-04 6:46 
GeneralRe: Double buffering with GDI+ Pin
Jorgen E.25-May-04 6:55
Jorgen E.25-May-04 6:55 
GeneralRe: Double buffering with GDI+ Pin
Jorgen E.23-Jun-04 8:21
Jorgen E.23-Jun-04 8:21 
QuestionHibernate event on WinXP ? Pin
Cris24-May-04 8:36
Cris24-May-04 8:36 
AnswerRe: Hibernate event on WinXP ? Pin
Graham Bradshaw24-May-04 13:37
Graham Bradshaw24-May-04 13:37 
GeneralReading .PSD file Pin
nachilau24-May-04 8:27
nachilau24-May-04 8:27 
GeneralRe: Reading .PSD file Pin
David Crow24-May-04 8:31
David Crow24-May-04 8:31 

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.