Follow us on Twitter!
It is the path of least resistance that makes rivers and men crooked. - Bj Palmer
Thursday, April 17, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 24
Guests Online: 20
Members Online: 4

Registered Members: 82818
Newest Member: Ahmed
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

Win32 handling WM_PAINT


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 27-08-08 00:43
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
Code
switch (message)
{
          //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


Code
case WM_LBUTTONDBCLK:
{
   //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;
}





Code
PAINTSTRUCT pS;
HDC hdc = BeginPaint(hwnd, &pS);
//stuff
EndPaint(hwnd, &pS);



didn't work

UpdateWindow and RedrawWindow didn't work either.




Edited by on 27-08-08 12:07
Author

RE: Win32 handling WM_PAINT


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 27-08-08 19:12
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.

Code
std::vector <POINT> EllipsePoints(42);


//global scope

then in callback
Code
case WM_LBUTTONDBCLK:
{
//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.




Edited by on 30-08-08 14:20