Frage zur automatischen Bildanpassung

  • VB6

Es gibt 1 Antwort in diesem Thema. Der letzte Beitrag () ist von Marcus Gräfe.

    Frage zur automatischen Bildanpassung

    Wie kann ich mit VB 6.0 eine automatische Bildanpassung einbauen?
    Mein Problem:
    Ich habe eine ListBox, aus der man Bilder auswählen kann. Beim Draufklicken erscheint in einem Vorschaufenster (ImageBox oder PictureBox) eine verkleinerte Darstellung des Bildes. Das Bild soll sich proportional an die Grösse des Fensters anpassen.
    Habe das Thema mal hierher verschoben, passt hier besser.

    Zu deinem Problem:

    Hier mal ein Auszug aus einem Programm von mir, vielleicht hilft dir das weiter:

    <pre><FONT SIZE=1 FACE=Courier New><FONT COLOR=#000080>Private</FONT> <FONT COLOR=#000080>Sub</FONT> SizeImg()
    <FONT COLOR=#000080>On</FONT> <FONT COLOR=#000080>Error</FONT> GoTo ErrorHandler

    <FONT COLOR=#000080>Dim</FONT> XYRatio <FONT COLOR=#000080>As</FONT> <FONT COLOR=#000080>Single</FONT>

    <FONT COLOR=#000080>With</FONT> imgView
    .Visible = <FONT COLOR=#000080>False</FONT>
    .Stretch = <FONT COLOR=#000080>False</FONT>
    <FONT COLOR=#000080>If</FONT> <FONT COLOR=#000080>Not</FONT> .Picture Is <FONT COLOR=#000080>Nothing</FONT> <FONT COLOR=#000080>And</FONT> .Width > 0 <FONT COLOR=#000080>And</FONT> .Height > 0 <FONT COLOR=#000080>Then</FONT>
    .Stretch = <FONT COLOR=#000080>False</FONT>
    <FONT COLOR=#000080>If</FONT> Me.ScaleWidth / .Width < Me.ScaleHeight / .Height <FONT COLOR=#000080>Then</FONT>
    XYRatio = Me.ScaleWidth / .Width
    <FONT COLOR=#000080>Else</FONT>
    XYRatio = Me.ScaleHeight / .Height
    <FONT COLOR=#000080>End</FONT> <FONT COLOR=#000080>If</FONT>
    .Move 0, 0, .Width * XYRatio, .Height * XYRatio
    .Stretch = (frmMain.chkFitToScreen.Value = 1)
    .Visible = <FONT COLOR=#000080>True</FONT>
    <FONT COLOR=#000080>End</FONT> <FONT COLOR=#000080>If</FONT>
    <FONT COLOR=#000080>End</FONT> <FONT COLOR=#000080>With</FONT>

    <FONT COLOR=#000080>Exit</FONT> <FONT COLOR=#000080>Sub</FONT>
    ErrorHandler:
    MsgBox Err.Description, vbCritical, "Fehler"
    <FONT COLOR=#000080>End</FONT> <FONT COLOR=#000080>Sub</FONT>

    </FONT></pre>
    Besucht auch mein anderes Forum:
    Das Amateurfilm-Forum