By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,558 Members | 1,673 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,558 IT Pros & Developers. It's quick & easy.

Moving Rectangle within a PictureBox Control

P: n/a
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.
Feb 15 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"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

Feb 16 '06 #2

P: n/a
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.

Feb 16 '06 #3

P: n/a
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" <De****@discussions.microsoft.com> wrote in message
news:D8**********************************@microsof t.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.

Feb 16 '06 #4

P: n/a
Maybe VB.Net 2005 provides a managed way to do this in .net code?
--
Dennis in Houston
"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" <De****@discussions.microsoft.com> wrote in message
news:D8**********************************@microsof t.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.


Feb 17 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.