Click here to Skip to main content
15,851,387 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When I draw a graph (put points) in the dialog box, about 70-80 percent is drawn, then redrawing starts from the very beginning. Then, at some point, the dialog box goes to the background, and after a while (after several redraws), the drawing ends and the dialog box comes to the foreground.

I thought that the redraw might be due to the fact that the dialog box is modal and the main application thread is blocked, and as a result, the drawing starts again. But I tried the modeless dialog as well. The result is the same

It should be noted that this behavior is observed only with a large number of drawn points. When there are few points, there are no redraws.

can anyone suggest why this behavior is observed

Thank u in advance!

What I have tried:

void CDialogGeometry::OnPaint()
	CPaintDC dc(this);

	CRect rect;

	// here I calculate x and y of a point in a loop 
	//for (...)
		//then I set a pixel
		dc.SetPixel(x, y, RGB(0, 0, 0));
Updated 8-Aug-23 4:06am
Andre Oosthuizen 8-Aug-23 9:07am    
Please show the code for the loop as I am certain that is where the redraw takes place.
Richard MacCutchan 8-Aug-23 11:56am    
It is usually better to draw the picture into a memory DC and then blit it into the actual view.
Idd Jutt 2021 9-Aug-23 7:42am    
I would agree with Richard MacCutchan, thats what I would do, but also would do the calculation in OnInitDialog() where can get the dimensions, just in case your calc is calling redraw

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900