Oct 8th, 2019, 12:11 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Center Picture2 in Picture1
How do I center Picture2 inside of Picture1
Code:
+------------------------------+
| Picture1 |
| |
| |
| +-------------+ |
| |Picture2 | |
| | | |
| | | |
| | | |
| +-------------+ |
| |
| |
| |
+------------------------------+
Oct 8th, 2019, 12:20 PM
#2
Fanatic Member
Re: Center Picture2 in Picture1
Use the Move method of Picture2, to both move it and resize it at the same time.
Oct 8th, 2019, 01:10 PM
#3
Re: Center Picture2 in Picture1
Use something along the lines of
Code:
top= (Picture1.ScaleHeight-picture2.height)/2
left=(picture1.scalewidth-picture2.width)/2
Oct 8th, 2019, 03:02 PM
#4
Re: Center Picture2 in Picture1
Originally Posted by
DataMiser
Use something along the lines of
Code:
top= (Picture1.ScaleHeight-picture2.height)/2
left=(picture1.scalewidth-picture2.width)/2
That code is OK if Picture1 is parent of Picture2 , if it isn't then you should use the following code
Code:
Picture2.Left = Picture1.Left + (Picture1.Width / 2) - (Picture2.Width / 2)
Picture2.Top = Picture1.Top + (Picture1.Height / 2) - (Picture2.Height / 2)
Oct 8th, 2019, 03:14 PM
#5
Thread Starter
Hyperactive Member
Re: Center Picture2 in Picture1
Using this code.....
top= (Picture1.ScaleHeight-picture2.height)/2
left=(picture1.scalewidth-picture2.width)/2
Picture1.Width = 514
Picture1.Height = 327
Picture2.Width = 65
Picture2.Height = 18
Both pictures have ScaleMode Pixels
this is what I get.....
Attached Images
Oct 8th, 2019, 03:19 PM
#6
Re: Center Picture2 in Picture1
Originally Posted by
Ordinary Guy
Using this code.....
top= (Picture1.ScaleHeight-picture2.height)/2
left=(picture1.scalewidth-picture2.width)/2
Picture1.Width = 514
Picture1.Height = 327
Picture2.Width = 65
Picture2.Height = 18
Both pictures have ScaleMode Pixels
this is what I get.....
See my above reply #4
Oct 8th, 2019, 03:21 PM
#7
Thread Starter
Hyperactive Member
Re: Center Picture2 in Picture1
OK, never mind post 5 I now see post 4. Everything OK now
Oct 8th, 2019, 03:39 PM
#8
Re: Center Picture2 in Picture1
Originally Posted by
Ordinary Guy
OK, never mind post 5 I now see post 4. Everything OK now
I think you have to think of setting Picture1 as parent of Picture2, this may save you a lot of extra calculation if you move both relatively, to do at run time
Code:
Private Sub Form_Load()
Set Picture2.Container = Picture1
End Sub
or at design time by cutting Picture2 and pasting it inside Picture1
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