Home All Groups Group Topic Archive Search About

Moving Rectangle within a PictureBox Control

Author
15 Feb 2006 10:40 PM
fripper
I am a real novice when it comes to the graphics class in VB 2005.  I have a
windows app with a large picture box control with a black background ...
except for a small rectangle that has an image in it.  A timer fires every
second or so and when it does I want to move the small rectangle within the
picture box to another location within the picture box.  I don't want to
copy the rectangle ... I want to move it and have the vacated rectangle
revert to the black background.  Now, this program is an upgraded version of
a VB .Net 2003 version I had written.  In that version I used the bitblt
function to move this box but, as is so often the case, that function is not
supported in VB 2005.  Can someone help me understand how to move a junk of
the screen from one location to another?  I would appreciate whatever
specificity you can provide ... I really am a novice!

Thanks.

Author
15 Feb 2006 11:50 PM
Armin Zingler
"fripper" <yo***@indiana.edu> schrieb
> I am a real novice when it comes to the graphics class in VB 2005. I have
> a windows app with a large picture box control with a black
> background ... except for a small rectangle that has an image in it.
>  A timer fires every second or so and when it does I want to move
> the small rectangle within the picture box to another location
> within the picture box.  I don't want to copy the rectangle ... I
> want to move it and have the vacated rectangle revert to the black
> background.  Now, this program is an upgraded version of a VB .Net
> 2003 version I had written.  In that version I used the bitblt
> function to move this box but, as is so often the case, that
> function is not supported in VB 2005.

What does "not supported" mean?

>  Can someone help me
> understand how to move a junk of the screen from one location to
> another?  I would appreciate whatever specificity you can provide
> ... I really am a novice!

The usual way is to repaint everything, including the rectangle at the new
position. The first, simplest way is to paint in the Picturebox' Paint
event. Call it's Invalidate method to trigger the Paint event in the Timer's
Tick event.


Armin
Author
16 Feb 2006 12:50 AM
Dennis
Why would you think bitblt is not supported.   This is a Windows API function
and has nothing to do with the .net framework.  I would guess that even the
new Vista has support for the bitblt function since it is widely used as a
basis for copying, moving, etc. pixels.
--
Dennis in Houston


Show quoteHide quote
"fripper" wrote:

> I am a real novice when it comes to the graphics class in VB 2005.  I have a
> windows app with a large picture box control with a black background ...
> except for a small rectangle that has an image in it.  A timer fires every
> second or so and when it does I want to move the small rectangle within the
> picture box to another location within the picture box.  I don't want to
> copy the rectangle ... I want to move it and have the vacated rectangle
> revert to the black background.  Now, this program is an upgraded version of
> a VB .Net 2003 version I had written.  In that version I used the bitblt
> function to move this box but, as is so often the case, that function is not
> supported in VB 2005.  Can someone help me understand how to move a junk of
> the screen from one location to another?  I would appreciate whatever
> specificity you can provide ... I really am a novice!
>
> Thanks.
>
>
>
Author
16 Feb 2006 8:46 PM
fripper
The bitblt function (as I understand it) requires a device context paramater
(actually two ... one for the source and one for the destination). VB 2005
gives an error message when compiling a bitblt call with, say, picPic1.hdc,
as the source device context parameter. According to the VB 2005
documentation device contexts are no longer necessary with GDI+. So the
question remains ... How do I copy picPic1 to picPic2 using bitblt?

Show quoteHide quote
"Dennis" <Den***@discussions.microsoft.com> wrote in message
news:D8C51462-27DD-4C60-86FB-B8C610030E88@microsoft.com...
> Why would you think bitblt is not supported.   This is a Windows API
> function
> and has nothing to do with the .net framework.  I would guess that even
> the
> new Vista has support for the bitblt function since it is widely used as a
> basis for copying, moving, etc. pixels.
> --
> Dennis in Houston
>
>
> "fripper" wrote:
>
>> I am a real novice when it comes to the graphics class in VB 2005.  I
>> have a
>> windows app with a large picture box control with a black background ...
>> except for a small rectangle that has an image in it.  A timer fires
>> every
>> second or so and when it does I want to move the small rectangle within
>> the
>> picture box to another location within the picture box.  I don't want to
>> copy the rectangle ... I want to move it and have the vacated rectangle
>> revert to the black background.  Now, this program is an upgraded version
>> of
>> a VB .Net 2003 version I had written.  In that version I used the bitblt
>> function to move this box but, as is so often the case, that function is
>> not
>> supported in VB 2005.  Can someone help me understand how to move a junk
>> of
>> the screen from one location to another?  I would appreciate whatever
>> specificity you can provide ... I really am a novice!
>>
>> Thanks.
>>
>>
>>
Author
17 Feb 2006 12:11 AM
Dennis
Maybe VB.Net 2005 provides a managed way to do this in .net code?
--
Dennis in Houston


Show quoteHide quote
"fripper" wrote:

> The bitblt function (as I understand it) requires a device context paramater
> (actually two ... one for the source and one for the destination). VB 2005
> gives an error message when compiling a bitblt call with, say, picPic1.hdc,
> as the source device context parameter. According to the VB 2005
> documentation device contexts are no longer necessary with GDI+. So the
> question remains ... How do I copy picPic1 to picPic2 using bitblt?
>
> "Dennis" <Den***@discussions.microsoft.com> wrote in message
> news:D8C51462-27DD-4C60-86FB-B8C610030E88@microsoft.com...
> > Why would you think bitblt is not supported.   This is a Windows API
> > function
> > and has nothing to do with the .net framework.  I would guess that even
> > the
> > new Vista has support for the bitblt function since it is widely used as a
> > basis for copying, moving, etc. pixels.
> > --
> > Dennis in Houston
> >
> >
> > "fripper" wrote:
> >
> >> I am a real novice when it comes to the graphics class in VB 2005.  I
> >> have a
> >> windows app with a large picture box control with a black background ...
> >> except for a small rectangle that has an image in it.  A timer fires
> >> every
> >> second or so and when it does I want to move the small rectangle within
> >> the
> >> picture box to another location within the picture box.  I don't want to
> >> copy the rectangle ... I want to move it and have the vacated rectangle
> >> revert to the black background.  Now, this program is an upgraded version
> >> of
> >> a VB .Net 2003 version I had written.  In that version I used the bitblt
> >> function to move this box but, as is so often the case, that function is
> >> not
> >> supported in VB 2005.  Can someone help me understand how to move a junk
> >> of
> >> the screen from one location to another?  I would appreciate whatever
> >> specificity you can provide ... I really am a novice!
> >>
> >> Thanks.
> >>
> >>
> >>
>
>
>