473,655 Members | 3,056 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 9275
"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****@discuss ions.microsoft. com> wrote in message
news:D8******** *************** ***********@mic rosoft.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****@discuss ions.microsoft. com> wrote in message
news:D8******** *************** ***********@mic rosoft.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
1248
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 serious problems with trasparence Create new project and add a button in the form and then insert a background image to the form itself.
6
4787
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 to move it around on the picture and delete it. Thanks Brad Shook
5
4696
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 rectangle that will allow the text to show through? I did try: myColor = Color.FromArgb(127, Color.GreenYellow) Dim fillBrush As New SolidBrush(myColor) but that isn't exactly the effect I wanted.
3
16125
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 = new Rectangle(int.Parse(this.txt_Left.Text), int.Parse(this.txt_Top.Text), ControlWidth, ControlHeight); pictureBox2.CreateGraphics().DrawRectangle(new Pen(Color.Red, 1), r);
2
9370
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
1459
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 to each other. However if they overlap they do obsure the picturebox underneath, even though the form background is still visible.
2
2224
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
2339
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 from the screen. here is my code private Rectangle r = new Rectangle(new Point(0,0), new Size(0,0));
6
7494
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 efficiently, I draw the text directly to the image. It's faster that way. The problem is that right now I have to redraw the original (unwritten-to) bitmap and redraw the text whenever the user moves the text because I haven't figured out how to properly...
0
8380
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8816
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8598
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5627
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4299
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2721
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1598
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.