vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
Top-Preis! AP-Access-Tools-CD Volume 1  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2024
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

VB.NET - Ein- und Umsteiger
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
alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
Picturebox relativ zur Parentbox verschieben951PowerBauer04.02.18 18:55
Re: Picturebox relativ zur Parentbox verschieben428Franki09.02.18 03:59
Re: Picturebox relativ zur Parentbox verschieben435Manfred X09.02.18 13:20
Re: Picturebox relativ zur Parentbox verschieben415PowerBauer09.02.18 16:34

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

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

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