|
-
May 10th, 2013, 05:36 AM
#1
-
May 10th, 2013, 06:08 AM
#2
Re: PictureBox screenshot
try setting your label's parent property:
Code:
Label1.Parent = PictureBox1
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
May 10th, 2013, 06:09 AM
#3
Re: PictureBox screenshot
Because you are only drawing the PictureBox. Don't you want to draw the form at the coordinates of the PictureBox?
-
May 10th, 2013, 06:23 AM
#4
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
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
May 10th, 2013, 06:38 AM
#5
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
-
May 10th, 2013, 06:42 AM
#6
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
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
May 10th, 2013, 06:47 AM
#7
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.
-
May 10th, 2013, 06:51 AM
#8
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
-
May 10th, 2013, 06:54 AM
#9
Re: PictureBox screenshot
 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

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.
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|