Win32 handling WM_PAINT
I know the WM_PAINT message is sent to my app when I minimize the window or put focus on any another window. I've seen lots of things that say you need to handle this message when it is sent, but they never really say how to do persistent drawing. A lot of things just say to always draw inside of WM_PAINT(C++).
If you minimize the window and restore it, you’ll notice that everything you’ve drawn is erased. This is because Windows sends the WM_PAINT message to your application telling it to redraw its client area. To keep persistent drawings, you’ve got two options – to keep a list of all objects and draw them on every call to WM_PAINT or to keep a snapshot of the image and redraw it on WM_PAINT.
I can't just do
//callback
{
//other messages
case WM_PAINT:
{
Shape(c1,c2);
AnotherShape(c1,c2);
break;
}
because the values aren't always going to be the same, and are triggered by events
{
//draw something centered over that coord;
break;
}
case WM_PAINT:
{
//do whatever is correct to keep what
//I just drew on the window after I minimize or whatever
break;
}```
```markupPAINTSTRUCT pS;
HDC hdc = BeginPaint(hwnd, &pS);
//stuff
EndPaint(hwnd, &pS);```
didn't work
UpdateWindow and RedrawWindow didn't work either.
I've been thinking of just doing what it said in the way of keeping track of the stuff and drawing it every time it gets WM_PAINT. It's not a ridiculous amount of points, I just don't want it to be really slow or anything.
markupstd::vector <POINT> EllipsePoints(42);
//global scope
then in callback
{
//set x and y of POINT structure, add that element to the vector
//draw it on the window
break;
}
case WM_PAINT:
{
//loop through vector of points & draw the stuff
break;
}```
Just a thought, I'll try it in a while. Any ideas welcome.
Edit: I just use an array of POINTS, the vector was fucking it up somehow.