Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi ,
As soon as the user holds down the left mouse button, i want to paint continuously unless he releases it.

Any suggestions.
Posted
Comments
Richard MacCutchan 18-Aug-11 15:35pm    
You don't want to do it that way.
[no name] 18-Aug-11 15:39pm    
i am really trying hard for this. please suggest me a way in implementing this feature.
TRK3 18-Aug-11 17:12pm    
You might want to explain why you think you want to do this, or what you are trying to accomplish by doing so.

Most of us read "paint continuously" and immediately think: "That's a bad idea."
[no name] 19-Aug-11 8:44am    
i want to draw an arrow moving from left to the right of the window as soon as the user holds down the Left mouse button. Once he releases the left mouse button then again one more arrow is to be moved from left to right.
Here arrow means i m drawing a line and then moving it using MoveToEx() and LineTo() functions

You could handle the WM_MBUTTONDOWN and WM_MBUTTONUP events.

Call SetCapture when you get the button down event so that you get the button up event even if he moves the cursor off the window.

I'm not sure what you mean by paint "continuously" -- but between the button down and up messages you will want to invalidate the paint region (as suggested by cPallini) "continuously".

Depending on what you mean by "continuously", use a timer to periodically invalidate it, or invalidate it on mouse move messages, or invalidate it when whatever you actually need to repaint it based on a change in the underlying thing you are painting.
 
Share this answer
 
You may periodically sample mouse input via GetAsyncKeyState[^] and invalidate the paint region accordingly.
 
Share this answer
 

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