Hallo zusammen!
Ich bin am basteln mit der UDF von Großvater (HIER)
Leider klappt es mit dem Seitenverhältnis nicht ganz.
In der UDF steht:
_GUICtrlPic_Create
; #FUNCTION# ====================================================================================================================
; Name...........: _GUICtrlPic_Create
; Description ...: Pic-Control für alle von GDIPlus unterstützten Formate ggf. mit Transparenz erstellen.
; Syntax.........: _GUICtrlPic_Create($sPicPath, $iLeft, $iTop[, $iWidth = 0[, $iHeight = 0[, $uStyles = -1[, $uExStyles = -1[, $bKeepAspectRatio = False]]]]])
; Parameters ....: Die Parameter entsprechen bis auf den letzten der AU3-Funktion GUICtrlCreatePic()
; $bKeepAspectRatio - Seitenverhältnis bei der Größenanpassung beachten:
; |True - ja
; |False - nein
; |Default - nein
; Return values .: Im Erfolgsfall: ControlID aus GUICtrlCreatePic()
; Im Fehlerfall: False, @error und @extended enthalten ergänzende fehlerbeschreibende Werte.
; Author ........: Großvater (http://www.autoit.de)
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func _GUICtrlPic_Create($sPicPath, $iLeft, $iTop, $iWidth = 0, $iHeight = 0, $uStyles = -1, $uExStyles = -1, $bKeepAspectRatio = False)
Local Const $IMAGE_BITMAP = 0x0000
Local Const $STM_SETIMAGE = 0x0172
Local $aResult, $hBitmap, $hImage, $Height, $Width, $CtrlID
Local $aBitmap = _GUICtrlPic_LoadImage($sPicPath)
If @error Then Return SetError(@error, @extended, False)
$hBitmap = $aBitmap[0]
$Width = $aBitmap[1]
$Height = $aBitmap[2]
If $iWidth = 0 And $iHeight = 0 Then
$iWidth = $Width
$iHeight = $Height
Else
$hBitmap = _GUICtrlPic_ScaleBitmap($hBitmap, $iWidth, $iHeight, $Width, $Height, $bKeepAspectRatio)
If @error Then Return SetError(@error, @extended, False)
EndIf
$CtrlID = GUICtrlCreatePic("", $iLeft, $iTop, $iWidth, $iHeight, $uStyles, $uExStyles)
GUICtrlSendMsg($CtrlID, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap)
DllCall("Gdi32.dll", "BOOL", "DeleteObject", "Handle", $hBitmap)
Return $CtrlID
EndFunc ;==>_GUICtrlPic_Create
$bKeepAspectRatio gleich 0 oder False klappen, 1 oder True nicht...
Allerdings steig ich auch nicht dahinter wo genau der Fehler liegt. Kann mir jemand weiterhelfen?
Besten Dank im Voraus
Anhang:
Probiert es doch mal mit dem letzten Beispiel:
Beispel
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include "GUICtrlPic.au3"
$bFirst = True
$Pic1 = @ProgramFilesDir & "\AutoIt3\Examples\GUI\Torus.png"
$Form1 = GUICreate("Form1", 400, 300)
GUICtrlCreatePic(@ProgramFilesDir & "\AutoIt3\Examples\GUI\Torus.png", 0, 0, 400, 300)
GuiCtrlSetState(-1,$GUI_DISABLE)
$a8 = _GUICtrlPic_Create($Pic1 , 30, 30, 72, 72)
GUISetState(@SW_SHOW)
Dim $GO = False
while 1
$ReadMouse = GUIGetCursorInfo() ; Pos mouse
If IsArray($ReadMouse) = 1 Then
Select
case $ReadMouse[4] = $a8 and $GO = False
_GUICtrlPic_SetImage($a8, @ProgramFilesDir & "\AutoIt3\Examples\GUI\Merlin.gif", 0)
$GO = True
case $ReadMouse[4] <> $a8 and $GO = True
_GUICtrlPic_SetImage($a8, @ProgramFilesDir & "\AutoIt3\Examples\GUI\Torus.png", 0)
$GO = False
EndSelect
EndIf
Switch GUIGetMsg()
case -3 ; $GUI_EVENT_CLOSE
exit
case $a8
_GUICtrlPic_SetImage($a8, @ProgramFilesDir & "\AutoIt3\Examples\GUI\msoobe.jpg", 0)
MsgBox(0,"","Pressed")
_GUICtrlPic_SetImage($a8, @ProgramFilesDir & "\AutoIt3\Examples\GUI\Torus.png", 0)
EndSwitch
WEnd
EDIT:
Wenn man die Style Parameter berücksichtigt klappt es auch...