Click to See Complete Forum and Search --> : Moving Rects -
.pcbrainbuster
November 17th, 2007, 07:43 PM
Sup dudes,
As some of you know I'm developing a another sort of paint program, and need to know how to do you move rects that have been selected by the user?
Thanks.
Marc G
November 19th, 2007, 03:19 AM
What kind of rects? How do you let the user select a rect?
If you want to move a part of a bitmap, you can use bitblt to blit a source rectangle to a destination rectangle.
.pcbrainbuster
November 19th, 2007, 12:19 PM
The user drags a rectangle of his/her choice and then can/should be able to drag that rectangle.
Thanks.
LoKi_79
November 19th, 2007, 04:58 PM
The user drags a rectangle of his/her choice and then can/should be able to drag that rectangle.
Thanks.just the rectangle outline? or the contents as well?
in either case it is the same.
for every WM_MOUSEMOVE you have to erase the last rectangle (what is behind the rectangle would depend on your program), then draw your new rectangle in the new position.
if it is temporary (i.e. an area selection box) you can simply invert the pixels to draw the box SetROP2(hdc, R2_NOT) , and then repeat that to put them back.
if you want to move around a rectangle of a specific colour, then you need to do more work - either do the whole operation on a separate bitmap/DC so you do not alter the original (important) one, or keep a back up copy of it so you can replace the pixels that need replacing when you erase the old ones. once you have got that working without flicker then you have made some good progress (do not use erase background or replace pixels unnecessarily).
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.