Click here to Skip to main content
15,878,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello people,
i am doing drawings on dialof in MFC vc++.

i am drawing lines as per the different inputs i am getting from the serial.

now i want to clear the drawings when i get another input.

What I have tried:

CClientDC dc(GetDlgItem(IDC_STATICDISPLAY));

CPen lDot(PS_DASH, 2, RGB(255, 255, 255));

dc.SelectObject(&lDot);
	dc.Rectangle(a,b,c,d);

Here a,b,c,d are my different inputs which i am getting from the serial communication.
at each input i want to clear the older drawings and draw a new lines with new data.

And
GetDlgItem(IDC_STATICDISPLAY)
is the group box in which i am drawing lines in dialog.
Posted
Updated 1-Aug-18 21:34pm

GetDlgItem(IDC_STATICDISPLAY)->Invalidate( true );

That will cause the group box to be erased and redrawn. Erased means the default background will be drawn for the control.
 
Share this answer
 
Comments
Member 12533122 2-Aug-18 1:40am    
GetDlgItem(IDC_STATICDISPLAY)->Invalidate( true );

THIS IS NOT WORKING. its still not clear the old drawing.
Jochen Arndt 2-Aug-18 3:02am    
Call GetDlgItem(IDC_STATICDISPLAY)->UpdateWindow() afterwards to force redrawing.
If the control is completly owner drawn that you should use FillRect with your bckground color at first draw call.

And I would suggest that you store the Windows-handle of the control and other constant objects (like the pen) as member variables to improve performance.
 
Share this answer
 
Comments
Member 12533122 3-Aug-18 7:27am    
i have done the same for temporary. i am drawing rect with background color and then draws the lines.
so like that every time i first draw blank rect and then draw a lines on it.

it helps me for now.

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