Hi,
ich würde gerne mit der Maus die GUI vergrößern.
Dabei soll während dem vergrößern sofort das Bild sich an die GUI anpassen.
Geht das?
Spoiler anzeigen
#Region ;************ Includes ************
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ScreenCapture.au3>
#EndRegion ;************ Includes ************
Global $iMinWidth, $iMaxWidth, $hwnd, $fRatio, $iMinHeight, $iMaxHeight, $hbmp, $hdcMem, $BITMAP
[/autoit] [autoit][/autoit] [autoit]Opt("GUIOnEventMode", 1) ; 0=ausgeschaltet, 1=OnEvent Modus aktiviert
[/autoit] [autoit][/autoit] [autoit]Global $bild_name = "C:\Windows\Web\Wallpaper\Windows\img0.jpg"
[/autoit] [autoit][/autoit] [autoit]_bild_in_gui("Bild123", $bild_name, 500, 200, 700)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Func _bild_in_gui($title_func, $bild_func, $iGUI_WidthInitial, $iMinWidth_func, $iMaxWidth_func)
Local $array_bildergroesse[3]
$iMinWidth = $iMinWidth_func
$iMaxWidth = $iMaxWidth_func
$BITMAP = "LONG bmType;" & "LONG bmWidth;" & "LONG bmHeight;" & "LONG bmWidthBytes;" & "WORD bmPlanes;" & "WORD bmBitsPixel;" & "PTR bmBits;"
[/autoit] [autoit][/autoit] [autoit];~ Global Const $HWND_DESKTOP = _WinAPI_GetDesktopWindow()
;~ $fRatio = _WinAPI_GetClientWidth($HWND_DESKTOP) / _WinAPI_GetClientHeight($HWND_DESKTOP)
$array_bildergroesse = _bildgroesse2($bild_func)
$fRatio = $array_bildergroesse[1] / $array_bildergroesse[2]
GUIRegisterMsg($WM_CREATE, "OnCreate")
GUIRegisterMsg($WM_ERASEBKGND, "OnEraseBkGnd")
GUIRegisterMsg($WM_SIZING, "WM_SIZING")
GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO")
$hwnd = GUICreate($title_func, $iGUI_WidthInitial, Floor($iGUI_WidthInitial / $fRatio), -1, -1, $WS_OVERLAPPEDWINDOW)
GUISetState(@SW_SHOW, $hwnd)
GUISetOnEvent($GUI_EVENT_CLOSE, "_bild_in_gui_beenden")
[/autoit] [autoit][/autoit] [autoit]$fRatio = _WinAPI_GetWindowWidth($hwnd) / _WinAPI_GetWindowHeight($hwnd)
[/autoit] [autoit][/autoit] [autoit];fehlende min. und max. Wert ermitteln
$iMinHeight = $iMinWidth / $fRatio ;min. Höhe anhand der min. Breite und des Seitenverhältnisse berechnen
$iMaxHeight = $iMaxWidth / $fRatio ;max. Höhe anhand der max. Breite und des Seitenverhältnisse berechnen
If $iMaxHeight > @DesktopHeight Then ;max. Höhe größer als der Bildschirm >>> neue max. Breite ermitteln
$iMaxHeight = @DesktopHeight
$iMaxWidth = $iMaxHeight * $fRatio
EndIf
;Schleife
While 1
Sleep(10)
WEnd
EndFunc ;==>_bild_in_gui
Func OnCreate($hwnd, $message, $wParam, $lParam)
Local $hdc
;~ $hbmp = _ScreenCapture_Capture()
;~ If (Not $hbmp) Then ConsoleWrite(StringFormat("_WinAPI_LoadImage fehlgeschlagen!\n")); error handling here
$hdc = _WinAPI_GetDC($HWND_DESKTOP)
$hdcMem = _WinAPI_CreateCompatibleDC($hdc)
_WinAPI_ReleaseDC($HWND_DESKTOP, $hdc)
[/autoit] [autoit][/autoit] [autoit]If (Not $hdcMem) Then ConsoleWrite(StringFormat("_WinAPI_CreateCompatibleDC fehlgeschlagen!\n")) ; error handling here
[/autoit] [autoit][/autoit] [autoit]Return $GUI_RUNDEFMSG
EndFunc ;==>OnCreate
Func OnEraseBkGnd($hwnd, $message, $wParam, $lParam)
Local $rcClient
Local $hObjOld
Local $rcRight, $rcBottom
Local $bmWidth, $bmHeight
Local $bm = DllStructCreate($BITMAP)
If (Not $hbmp) Then Return 1
[/autoit] [autoit][/autoit] [autoit]; get the window's client area
$rcClient = _WinAPI_GetClientRect($hwnd)
$rcRight = DllStructGetData($rcClient, "Right")
$rcBottom = DllStructGetData($rcClient, "Bottom")
; get the bitmap dimensions
_WinAPI_GetObject($hbmp, DllStructGetSize($bm), DllStructGetPtr($bm))
; select the bitmap into the memory DC
$hObjOld = _WinAPI_SelectObject($hdcMem, $hbmp)
$bmWidth = DllStructGetData($bm, "bmWidth")
$bmHeight = DllStructGetData($bm, "bmHeight")
DllCall("gdi32.dll", "INT", "SetStretchBltMode", "HANDLE", $wParam, "INT", 4)
[/autoit] [autoit][/autoit] [autoit]StretchBlt($wParam, 0, 0, $rcRight, $rcBottom, $hdcMem, 0, 0, $bmWidth, $bmHeight, $SRCCOPY)
[/autoit] [autoit][/autoit] [autoit]_WinAPI_SelectObject($hdcMem, $hObjOld)
[/autoit] [autoit][/autoit] [autoit]Return 1
EndFunc ;==>OnEraseBkGnd
Func StretchBlt($hdcDest, $nXOriginDest, $nYOriginDest, $nWidthDest, $nHeightDest, $hdcSrc, $nXOriginSrc, $nYOriginSrc, $nWidthSrc, $nHeightSrc, $dwRop)
Local $aRes = DllCall("gdi32.dll", "BOOL", "StretchBlt", "HANDLE", $hdcDest, "INT", $nXOriginDest, "INT", $nYOriginDest, "INT", $nWidthDest, "INT", $nHeightDest, "HANDLE", $hdcSrc, "INT", $nXOriginSrc, "INT", $nYOriginSrc, "INT", $nWidthSrc, "INT", $nHeightSrc, "DWORD", $dwRop)
Return $aRes[0]
EndFunc ;==>StretchBlt
Func WM_GETMINMAXINFO($hwnd, $Msg, $wParam, $lParam)
Local $minmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
DllStructSetData($minmaxinfo, 7, $iMinWidth) ; min X
DllStructSetData($minmaxinfo, 8, $iMinHeight) ; min Y
DllStructSetData($minmaxinfo, 9, $iMaxWidth) ; max X
DllStructSetData($minmaxinfo, 10, $iMaxHeight) ; max Y
Return "GUI_RUNDEFMSG"
EndFunc ;==>WM_GETMINMAXINFO
Func WM_SIZING($hwnd, $iMsg, $wParam, $lParam)
Local $tRect_Cur = DllStructCreate("int[4]", $lParam)
Local $left = DllStructGetData($tRect_Cur, 1, 1)
Local $top = DllStructGetData($tRect_Cur, 1, 2)
Local $right = DllStructGetData($tRect_Cur, 1, 3)
Local $bottom = DllStructGetData($tRect_Cur, 1, 4)
Switch $wParam ;drag side or corner
Case 1, 2, 4, 7
Local $iNewY = Int(($right - $left) / $fRatio)
DllStructSetData($tRect_Cur, 1, $top + $iNewY, 4)
Case Else
Local $iNewX = Int(($bottom - $top) * $fRatio)
DllStructSetData($tRect_Cur, 1, $left + $iNewX, 3)
EndSwitch
Return "GUI_RUNDEFMSG"
EndFunc ;==>WM_SIZING
Func _bild_in_gui_beenden()
; free resources
_WinAPI_DeleteObject($hbmp)
_WinAPI_DeleteDC($hdcMem)
GUIDelete($hwnd)
EndFunc ;==>_bild_in_gui_beenden
Func _bildgroesse2($bildgroesse_pfad_dateiname)
Local $array_bilder_1[3], $hImage3
; Initialisiert (startet) Microsoft Windows GDI+
_GDIPlus_Startup()
; Lädt ein Bild
$hImage3 = _GDIPlus_ImageLoadFromFile($bildgroesse_pfad_dateiname)
; Erzeugt eine Kopie einer 24 bit Bitmap
$array_bilder_1[1] = _GDIPlus_ImageGetWidth($hImage3)
$array_bilder_1[2] = _GDIPlus_ImageGetHeight($hImage3)
; Ressourcen freigeben
_GDIPlus_ImageDispose($hImage3)
; Gibt die durch Microsoft Windows GDI+ verwendeten Ressourcen wieder frei
_GDIPlus_Shutdown()
Return $array_bilder_1
EndFunc ;==>_bildgroesse