473,326 Members | 2,182 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Moving Rectangle within a PictureBox Control

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
4 9258
"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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Gino | last post by:
Hi, I wish to code a control that writes a text over a picturebox and that can be dragged with mouse. Here is what i've actually coded to obtain a similar effect, but as you can see i've...
6
by: Brad Shook | last post by:
Can someone point me to an example or post some code on how to allow a user to draw a rectangle on top of an image and retrieve the coordinates and dimensions of it. They will also need to be able...
5
by: DazedAndConfused | last post by:
I have a rectangle around text that I want to fill in with color. I do not know the height of the rectangle until I actually go through and draw out the text. Is there a way of filling in the...
3
by: emferrari | last post by:
Hi all I have a picturebox which I will have a image loaded to it and some text fields with coordinates. I am drawing a rectangle according to the coordinates in the text fields. Rectangle r...
2
by: Diogo Alves - Software Developer | last post by:
Greetings I would like to knowhow can I put a sliding panel... I've done this: if (panel1.Width < 300) { while (panel1.Width < 300) { panel1.Width = panel1.Width + 40;
2
by: toby | last post by:
Hi, After the great help I received to create PictureBox arrays I now have another problem. I want to be able to position transparent pictureboxes (with a small rectangle drawn in them) next...
2
by: pattex007 | last post by:
Hey can anybody help me? I can't move elipse within a PictureBox and timer how can i do this??
0
by: Red Head | last post by:
Hello I've written some code to draw a rectangle on a picture box when the user moves the mouse. (the previous rectangle is cleared) This works fine but the very first rectangle is not removed...
6
by: bradyounie | last post by:
I'm writing a program that displays a user-supplied Bitmap and then writes text fields to it. These "text fields" are things that the user can move around on the image, but to render them...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.