Draw A Line Over A Picture Box Using The Paint Event?

Apr 7, 2011

How would I draw a line over a Picture Box using the Paint event? I can draw the lines but they are drawn under the Picture Boxes.

View 6 Replies


ADVERTISEMENT

VB Panel Paint Event And Picture File

Mar 25, 2010

I have a panel in my mainform and need to display a jpg file on it using a paint event. Any suggestion how can i go about doing it. I have to use a menu item to open a folder i.e. OpenDiaolgFolder to open a jpg file.

View 6 Replies

Can't Draw Line In Picture Box

Jun 21, 2010

How come this doesn't work...

Private Sub ColorKeyForm_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
'Draws diagonal line of dot and dash on form

[Code]....

... the top part draws a line on the form but the second part does nothing. The picColorKey is a picture box on the form.

View 2 Replies

Draw A Line On A Picture?

Jun 29, 2009

I need to draw a line on a series of pictures: I have decompiled a movie file to 1200 pictures. I also have 1200 samples of vector data (coordinates of the line: beginning point, ending point , size of vector (length) and direction (angle)... anything). With these data I want for each corresponding picture to draw a line corresponding to this vector data for instance: picture 550 needs to get a line drawn from point (5,95) ... these are (x,y) coordinates. in direction of 5 degrees from a vertical line and length 55. Visual Basic do that? I understand there will be some work in locating the origin of the x,y coordinate system and telling the program what 'size 1' means...

View 4 Replies

How To Draw A Line On An Image In A Picture Box

Feb 8, 2006

I want to draw a line on an image in a picture box. How do I do? The picture box is placed as the only item in a standard form. The following doesn't work:Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint

Dim TestLine As System.Drawing.Graphics
TestLine = PictureBox1.CreateGraphics
Dim TestPen As New System.Drawing.Pen(System.Drawing.Color.Red)
TestLine.DrawLine(TestPen, 10, 10, 50, 50)
TestPen.Dispose()
End Sub

The corresponding method for the paint event works fine in a panel, but the picture box doesn't seem to support it. What am I doing wrong?

View 2 Replies

How To Draw Black Line Across Center Of Picture

Feb 19, 2010

I have to draw a black line across the center of the picture from one side to the other, how do I do that. Here is the code:
Dim bmp As Bitmap
Dim x, y As Integer
Dim pixel As Color
lblLeft.Image = Image.FromFile(tbFileName.Text)
bmp = Bitmap.FromFile(tbFileName.Text)
' manipulate bmp here
lblRight.Image = bmp

View 1 Replies

VS 2008 - Picture Box - Draw On A Line On Top Of The Image

Oct 21, 2009

Is it possible to have a picture box and draw on a line on top of the image that is in there with the basic express package?

View 3 Replies

PictureBox Has An Image Alignment Or Offset Error When Using E.graphics.drawimage In The Picture Boxs' Paint Event?

Apr 17, 2010

I have tried to realign the image by down and right one pixel, but still only part of the first row and column are visible when zoomed.I can't find exactly what I'm looking for online.

My computer is an HP-Pavillion dv9600 Notebook PC.

OS: Windows Vista SP2 32-bit

The following code reproduces the problem:

Public Class PictureBug
Dim pxlColor As Color
Dim img As Bitmap = New System.Drawing.Bitmap(My.Resources.TestBug[code]......

View 7 Replies

Cause An Event - Draw A Solid Black Line 25 Pixels From The Top Of The Form?

Jan 31, 2012

I see that the Line method is replaced with DrawLine, however; it seems like DrawLine must treated as an object as follows:

Private Sub Form1_Paint(ByVal sender As Object, ByVal e _

As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint

Draw a solid black line 25 pixels from the top of the form.[code].....

When I attempt to use this code (call it), I must somehow bring about an event, but I haven't found how to do that.How do I "call" this sub?

View 13 Replies

Draw And Paint Without Creating Infinite Loop?

Dec 10, 2010

I wanted to draw a chart on a picture box. So I create a form, put a picture box on it, and then in the code of Form_load, I put a handler to the paint event of the picture box. This seems to create an infinite loop, judging from the behavior of the form.

View 19 Replies

Paint And Zoom On A Picture?

Dec 7, 2011

Ive been hacking away at this portion of a project for some time and I have a Picbox in a panel, I can, Draw on the image no problem, I can pan and then draw on the image, no problem. How ever when I zoom in out out on the image I can no longer draw on the zoomed image. How ever if I try and draw then zoom again, the lines will show up, but in the wrong places

[Code]...

View 9 Replies

VB App Pasting A Picture Into Paint?

Aug 29, 2010

I am making a screenshot saver/viewer and I want to be able to click on the PictureBox1 when it has an image inside it, and have it open up "mspaint.exe" and paste the contents of the PictureBox1 Image into Paint. How can I do this? [code]

View 5 Replies

How To Make Tetris Using Paint Or Picture Boxes

Apr 15, 2012

I'm sure this has been asked before and I even searched but could not get the source code downloaded from skydrive. So I'm looking for a good youtube video tut on how to make Tetris in Vb using paint or picture boxes. I'd preffer using picture boxes but making the shapes using paint arg would be fine.

View 13 Replies

Cause Paint Event To Fire From Click Event?

Feb 15, 2012

How can I cause the Paint event to fire from a Form_Click() event? This is what I'm trying to do...

Public Class StrTests01
Private Sub StrTests01_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
Dim ps As Graphics = Me.CreateGraphics()

[code]....

View 2 Replies

VS 2010 - Draw A Straight Line Between Two Points And Calculate The Length Of That Line?

Jan 3, 2012

I have a picture in my picturebox. In that picture, I need to draw a straight line between two points and calculate the length of that line (probably in pixels). Is there any suggestion how to do it?

View 2 Replies

How To Draw A DASHED Line Instead Of A Solid Line

Aug 22, 2010

I am graphing using Visual Basic graphics and it works. I would like to know how to draw a DASHED line instead of a solid line. Could someone help me with this?gphFormGraphics.DrawLine(Pens.Green, pt2, pt1)

View 4 Replies

Forcing A Paint Event?

Oct 3, 2009

The only way I know to force a paint event in my pictureboxes is to do a 'Picturebox1.invalidate'. I read that this isn't the best way to do it though, so what's the best way to make my picture boxes repaint?

View 8 Replies

Form Paint Event In .net?

Sep 10, 2009

Weird issue: I have application that I fire some code in the Form_Paint event for the main form, it works fine on my machine, but on other machines is not working at all.

I tried to debug the code on the other machine, and Form_Paint event is not triggered at all!

View 3 Replies

Multithreading Using A Paint Event

Nov 28, 2009

I was wondering how i would go about threading a paint event. I know the basic multithreading but i cant figure out how i would go about applying this on a paint event. This is the way i know how to go about multithreading.

[Code]...

View 2 Replies

Paint Event Goes Behind Objects?

Mar 27, 2011

so im making a projectile motione simulator for physics project got it all working and im drawing the path of the object with this code

e.Graphics.DrawRectangle(Pens.Red, 25 + xcord(counter1), 600 - ycord(counter1), 1, 1)

however it will draw it behind objects for example if i have a groupbox it will draw(i assume its still drawing at leaste) behind the group box and i cant see it

View 7 Replies

Update A Paint Event?

Dec 29, 2010

[url]... I managed to figure out how to paint a bitmap on a form. With some slight modification, I managed to make it so that the position of the bitmap can change based on key strokes.However, for some reason, it only does this once. It can't be that the xPosition and yPosition aren't responding since I rigged two labels to tell me their values and they are changing. So how can I make the bitmap respond.[code]...

View 1 Replies

Create A Track Bar Using Paint Event?

May 19, 2012

I want to create a track bar using paint event, but the problem is on mouse move event<Me.Invalidate()> is very slow since the graphic become unvisible for milli seconds and then return back, is there a way to make it faster?(doesn't become invisible)

View 2 Replies

Form Never Raise Paint Event?

Nov 12, 2011

i've an owned form that never raise the paint event, and so i can't make it rounded...

View 6 Replies

PictureBox Paint Event (With GDI Rectangle)?

Jul 23, 2007

correct way to draw rectangles onto a picturebox, and also to explain the paint event more clearly.Basically I have an application where a picturebox contains an image, this image is a small computer monitor as such:

The idea of this part of my application is that the user can draw small window size rectangles which represent windows later on. I have already used some excellent code on this forum to be able to draw the rectangles on the picturebox (As pictured above), the rectangle outline is drawn from MouseDown and MouseUp respectivley.

The problem I am encountering is with the 'repainting' of this rectangle. I have included code to repaint the rectangle in the Paint event of the picturebox. This works when you move the picturebox 'off screen' and bring it back. However when the form is re-sized or other various things occur the rectangle is not re-drawn? even though the picturebox 'appears' to be clean and always there!

My code is below, it is not full and complete, but the few main subs listed should give an indication as to how I am currently creating the rectangle:

Private Sub picboxAdvDisplay_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picboxAdvDisplay.MouseDown
'Set the flag for Drawing enabled

[code]....

1. What is the CORRECT way to draw a rectangle onto a Picturebox?

2. How do you code so that the rectangle is ALWAYS visible/drawn on a form re-size, minimise, window overlap etc etc.

View 11 Replies

Put The Code Of A Paint Event In A Different Thread?

Aug 18, 2009

the code below doesn't works...

[Code]...

View 1 Replies

Raise The Paint Event Of A Form?

Nov 11, 2011

during the development of my project, i've the need to raise the paint event of a form, to make it with rounded angle.The strange thing is that, when i use the invalidate comand on it, the repaint event (that sometimes doesn't go and i don't know why), doesn't make it like i need, that is, the dimension of the side is one instead of six pixel, and the angle are rounded, but the border is not visible.

View 1 Replies

Unable To Use Debugger During Paint Event?

Oct 14, 2009

I've got a bug in my program that I can't work out, during a paint event. The only way I can think to solve it is to watch the screen being updated one thing at a time. Problem is, I've put a break in and then I try stepping through the program one line at a time, but when I go to look at the screen it's blank - probably because I'm in the middle of a paint event? Is there some way that I can get my screen to update after each command?

View 4 Replies

Update Paint Event Coordinates?

Mar 31, 2009

I am trying to use the key's W and S to change the Y cordinate of a rectangle. The key's work, but the graphic doesnt update [code]...

View 4 Replies

VS 2008 GDI And Paint Event Handling?

Aug 26, 2009

From jmchillihiney's most excellent code bank sumission on Drawing:Quote:The way GDI+ works, controls get repainted on screen over and over again, sometimes many times in quick succession. On each of these occasions the control's Paint event is raised. You need to use the Paint event of the control to perform your own drawing or else, the next time the control is repainted, your drawing will just disappear as the control paints over it.

When you're creating a custom control you should override the OnPaint method and perform your drawing there. When you're designing a form or user control and you want to add custom drawing to a child control you handle that control's Paint event, then perform your drawing in the event handler.

You may have seen, or heard people talk about, controls flickering on screen. That's caused by repainting large areas of the control repeatedly and happens because painting on screen is actually quite a slow process. As such, you should try to do as little of it as possible.So, I am attempting to draw part of a custom control. I have placed a SplitContainer on a UserControl, and oriented it vertically. I then shrunk to top panel to 15 pixels in height. I have two Methods which each draw a different type of Path + fill into the panel, and then draw a border around it (One is a gradient fill, and the other is just a plain color). The idea is that when the user clicks on this panel, it switches from one to the other (a "Selected State" and "Not-Selected" state).

I have also created an icon which looks like the +/- widget on a treeview (or more specifically, on the vs2008 Toolbox, which is essentially what I am trying to emulate here . . .) which toggles as the control is selected/unselected. Not that ultimately, the selected state will change when the user selects OTHER controls, but the Expand/Collapse gizmo will toggle when the user clicks on the panel in question.

Again, check out the vs2008 toolbox. The Group "headers" are what I am after here. Believe it or not, all of this now WORKS (gee me, look what I did!) EXCEPT the initialization. If I "Handle" the paint event of the SplitCOntainer.Panel1 object in any way which prevents the flickering jmc alludes to above, any redrawing required by either initialization OR hiding/unhiding of the host form is prevented. And it seems like the SplitContainer panel is constantly redraing (probably checking to see if the splitter has been moved).

I can post some code, but it is a little confusing, since I am dealing with some semi-complex interaction here. Also, It is not necssecarily structured well ()yet). AFTER I figured out the drawing bits, THEN I was going to try to do some refactoring and restructuring. Code Follows in next post.

View 2 Replies

Forms :: Uses A Button To Draw A Line And A Second Button To Draw A Rectangle?

Oct 14, 2011

I have a form that uses a button to draw a line and a second button to draw a rectangle. I have a third button to clear the form but can't find a code example to code the Clear button.

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved