1 Attachment(s)
[RESOLVED] PictureBox screenshot
I have reached a mind block. This is what I have. A label control inside the picturebox.
Attachment 99913
I am not able to get label1 screenshot with picturebox1 screenshot. Couple of days ago I did manage that but now it is not working... Not sure what did I change.
Re: PictureBox screenshot
try setting your label's parent property:
Code:
Label1.Parent = PictureBox1
Re: PictureBox screenshot
Because you are only drawing the PictureBox. Don't you want to draw the form at the coordinates of the PictureBox?
Re: PictureBox screenshot
@Paul: I am aware of that but the problem with that is it will change the co-ordinates of the label and hence I will not get the exact screenshot which I want.
@dbasnett: Yes we can do that as well. But the same code was working till yesterday. I don't know what did I change :(
Re: PictureBox screenshot
If you place the Label exactly where you want it on the form, here's how to change it's parent without changing its absolute location:
Code:
Private Sub SetParentWithoutMoving(child As Control, newParent As Control)
child.Location = newParent.PointToClient(child.PointToScreen(Point.Empty))
child.Parent = newParent
End Sub
Re: PictureBox screenshot
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Label1.Parent IsNot PictureBox1 Then
Dim position As Point = Label1.Location
Label1.Parent = PictureBox1
position.Offset(-PictureBox1.Left, -PictureBox1.Top)
Label1.Location = position
End If
PictureBox1.DrawToBitmap('etc
End Sub
Re: PictureBox screenshot
The easiest way to resolve your problem without any coding is to simply replace your PictureBox with some container control.
e.g. Replace your PictureBox with a Panel control and retry whatever you were doing. If you face some difficulty, use the "Document Outline" window to ensure that your child controls (Label in this case), are children of your Panel control.
Re: PictureBox screenshot
Try this code, it is capture the screen region occupied by Picture1
Code:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim imgBmp As New Bitmap(PictureBox1.Width, PictureBox1.Height)
Dim gfx As Graphics = Graphics.FromImage(imgBmp)
Dim sr As Rectangle = RectangleToScreen(PictureBox1.Bounds)
gfx.CopyFromScreen(sr.Left, sr.Top, 0, 0, imgBmp.Size)
imgBmp.Save("g:\Sample.bmp", Imaging.ImageFormat.Bmp)
'PictureBox2.Load("g:\Sample.bmp")
End Sub
1 Attachment(s)
Re: PictureBox screenshot
Quote:
Originally Posted by
Pradeep1210
The easiest way to resolve your problem without any coding is ....
Thank You gents. I liked Pradeep's idea of using a panel instead of picturebox. I just tested it and it suits my need perfectly. Let me explain what I was actually trying to do. I am creating a an App which will let you create VBF flair which you can then use in your blogs and websites. See this Example
Attachment 99915
This was the last piece of the puzzle, Now I can post the App in the Utility Bank.
@Rest: I will try your codes as well. Thanks.