| |
VB.NET - Ein- und UmsteigerPicturebox relativ zur Parentbox verschieben | | | Autor: PowerBauer | Datum: 04.02.18 18:55 |
| Hallo,
beim Start meines Programms wird 1. die Form maximiert und 2. eine Picturebox (=PicSaloon) entsprechend vergrößert.
Das funktioniert. - Nun habe ich eine zweite Picturebox (=PicWhiskey1) auf der ersten platziert. Konkret steht die Whiskeyflasche auf dem Tresen. Nach dem Vergrößern steht die Whiskeyflasche immer noch am selben Ort - also nicht mehr auf dem Tresen. Man kann das sicherlich ausrechnen, wo genau die dann stehen muss - aber bei einer anderen Auflösung stimmt die Rechnung dann evtl. nicht mehr.
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
picWhiskey1.Parent = PicSaloon
PicSaloon.Width = Me.Width
PicSaloon.Height = CInt(Me.Height * 0.8)
End Sub Hat jmd eine Idee? | |
Re: Picturebox relativ zur Parentbox verschieben | | | Autor: Franki | Datum: 09.02.18 03:59 |
| Hallo,
da musst du halt die Auflösung des Users, die deiner Bilder des Users Fenstergröße usw. mit in deine Berechnung einbeziehen. Das ist alles reine Mathematik, mehr nicht.
Dir sollten ja alle notwendigen Werte schon bekannt sein.
Ohne konkrete Berechnungen wird das nichts...
Gruß
Frank | |
Re: Picturebox relativ zur Parentbox verschieben | | | Autor: Manfred X | Datum: 09.02.18 13:20 |
| Hallo!
Wer kann schon Mathe ????
Einfacher geht es, wenn man die Anpassung von Location und Size
der Zoom-Methode der Picturebox überläßt.
Public Class FrmAnimation
Dim WithEvents Pbox As New PictureBox With
{.Parent = Me, .SizeMode = PictureBoxSizeMode.Zoom, _
.Dock = DockStyle.Fill}
Dim bmpBackground As New Bitmap(400, 400, _
Imaging.PixelFormat.Format24bppRgb)
Dim bmpAnimation As New Bitmap(bmpBackground.Width, bmpBackground.Height)
Dim bmpForeGround1 As New Bitmap(20, 20, Imaging.PixelFormat.Format24bppRgb)
Dim bmpForeGround2 As New Bitmap(10, 10, Imaging.PixelFormat.Format24bppRgb)
Dim WithEvents TimAnimation As New Timer With _
{.Interval = 40, .Enabled = True}
Dim Posx1, Posy1, Posx2, Posy2 As Integer
Private Sub FrmAnimation_Load(sender As Object, _
e As EventArgs) Handles MyBase.Load
Me.DoubleBuffered = True
Using gr As Graphics = Graphics.FromImage(bmpBackground)
gr.Clear(Color.Yellow)
End Using
Using gr As Graphics = Graphics.FromImage(bmpForeGround1)
gr.Clear(Color.Blue)
End Using
Using gr As Graphics = Graphics.FromImage(bmpForeGround2)
gr.Clear(Color.Red)
End Using
Pbox.Image = bmpAnimation
End Sub
Private Sub TimAnimation_Tick(sender As Object, _
e As EventArgs) Handles TimAnimation.Tick
Static vz1 As Integer = 1
Posx1 = Posx1 + vz1 * 10 : Posy1 = Posy1 + vz1 * 5
Static vz2 As Integer = 1
Posx2 = Posx2 + vz2 * 5 : Posy2 = Posy2 + vz2 * 10
If Posx1 > bmpBackground.Width - bmpForeGround1.Width _
Or Posx1 < 0 _
Or Posy1 > bmpBackground.Height - bmpForeGround1.Height _
Or Posy1 < 0 Then _
vz1 *= -1
If Posx2 > bmpBackground.Width - bmpForeGround2.Width _
Or Posx2 < 0 _
Or Posy2 > bmpBackground.Height - bmpForeGround2.Height _
Or Posy2 < 0 Then _
vz2 *= -1
Using gr As Graphics = Graphics.FromImage(bmpAnimation)
gr.DrawImage(bmpBackground, 0, 0)
gr.DrawImage(bmpForeGround1, Posx1, Posy1)
gr.DrawImage(bmpForeGround2, Posx2, Posy2)
End Using
Pbox.Invalidate()
End Sub
End Class | |
Re: Picturebox relativ zur Parentbox verschieben | | | Autor: PowerBauer | Datum: 09.02.18 16:34 |
| Danke | |
| Sie sind nicht angemeldet! Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.
Einloggen | Neu registrieren |
|
|
Neu! sevDTA 3.0 Pro
SEPA mit Kontonummernprüfung
Erstellen von SEPA-Dateien mit integriertem BIC-Verzeichnis und Konto- nummern-Prüfverfahren, so dass ungültige Bankdaten bereits im Vorfeld ermittelt werden können. Weitere InfosTipp des Monats TOP Entwickler-Paket
TOP-Preis!!
Mit der Developer CD erhalten Sie insgesamt 24 Entwickler- komponenten und Windows-DLLs. Die Einzelkomponenten haben einen Gesamtwert von 1605.50 EUR...
Jetzt nur 599,00 EURWeitere Infos
|
|
|
Copyright ©2000-2024 vb@rchiv Dieter Otter Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.
Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel
|
|