-
September 28th, 2012, 05:09 PM
#1
[Quest] How to restore Objects of Window after WM_PAINT Message
I want to know how to restore objects that appear on window I will expalin in one Example;
Example (1)
case WM_COMMAND:
/////// Draw One Line
hdc=GetDC(hWnd);
MoveToEx(hd1,300,20,NULL);
LineTo(hd1,400,20);
ReleaseDC(hWnd,hd1);
/////////////////////////
My Problem Now is , if I the Application sends WM_PAINT message , I see the line is disappeared,
I know I can Draw the line under WM_PAINT message, But if I want to draw Line by using WM_COMMAND message , is thesr any tool to let me keep the objects on the window after application sent WM_PAINT Message.
I try to use InvalidateRect() function but It was not working..
Thanks & Regards
-
September 29th, 2012, 02:27 AM
#2
Re: [Quest] How to restore Objects of Window after WM_PAINT Message
The only one reliable place to draw something in window client area, is under WM_PAINT message.
From any another place (e.g. from a command message) call InvalidateRect or RedrawWindow.
That didn't work for you most possible because a mistake in your code.
-
September 29th, 2012, 11:07 AM
#3
Re: [Quest] How to restore Objects of Window after WM_PAINT Message
Thanks oviducucu,
And I hope to find solution ,
My Question is : How to get the content of window (Lines and dots) and restore it again after sending WM_PAINT message
I hope Igor will provide us his effective answers..
-
September 30th, 2012, 07:14 AM
#4
Re: [Quest] How to restore Objects of Window after WM_PAINT Message
The main principle: window must be able to redraw itself at any moment of its life.
This means:
- application should support Model approach: a number of data structures containing every entity information at least in aspect of drawing. Typically this is implemented as a polymorphic class hierarchy for drawing primitives/shapes/sprites. The drawing primitive instances appear stored in containers of an appropriate type
- application should support View approach: a rendering logic able to proceed based on the Model data. Typically this rendering occurs in response to every WM_PAINT message.
- application should support Controller approach: a logic for changing Model data in response to input from user or any other source of events. Typically Controller is comprised of a number of message handlers performing changes to Model and initiating window self redraw by means of InvalidateRect. Ideally this should be a single per-window class implementing controlling logic.
In accordance with this MVC approach you have your drawing not scattered all over the window procedure but being neatly structured and reliably tidy.
Last edited by Igor Vartanov; September 30th, 2012 at 07:23 AM.
Best regards,
Igor
-
September 30th, 2012, 07:27 AM
#5
Re: [Quest] How to restore Objects of Window after WM_PAINT Message
See this post as a demo for the approach above.
Best regards,
Igor
-
October 4th, 2012, 09:24 PM
#6
Re: [Quest] How to restore Objects of Window after WM_PAINT Message
Thanks Igor for your proffesional answers ;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|