Bildgröße laufend an GUI anpassen

  • 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
    [autoit]

    #Region ;************ Includes ************
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <ScreenCapture.au3>
    #EndRegion ;************ Includes ************

    [/autoit] [autoit][/autoit] [autoit]

    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]

    [/autoit] [autoit][/autoit] [autoit]

    $iMinWidth = $iMinWidth_func
    $iMaxWidth = $iMaxWidth_func

    [/autoit] [autoit][/autoit] [autoit]

    $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]

    [/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_CREATE, "OnCreate")
    GUIRegisterMsg($WM_ERASEBKGND, "OnEraseBkGnd")
    GUIRegisterMsg($WM_SIZING, "WM_SIZING")
    GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO")

    [/autoit] [autoit][/autoit] [autoit]

    $hwnd = GUICreate($title_func, $iGUI_WidthInitial, Floor($iGUI_WidthInitial / $fRatio), -1, -1, $WS_OVERLAPPEDWINDOW)
    GUISetState(@SW_SHOW, $hwnd)

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

    ;Schleife
    While 1
    Sleep(10)
    WEnd
    EndFunc ;==>_bild_in_gui

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func OnCreate($hwnd, $message, $wParam, $lParam)
    Local $hdc

    [/autoit] [autoit][/autoit] [autoit]

    ;~ $hbmp = _ScreenCapture_Capture()
    ;~ If (Not $hbmp) Then ConsoleWrite(StringFormat("_WinAPI_LoadImage fehlgeschlagen!\n")); error handling here

    [/autoit] [autoit][/autoit] [autoit]

    $hdc = _WinAPI_GetDC($HWND_DESKTOP)
    $hdcMem = _WinAPI_CreateCompatibleDC($hdc)

    [/autoit] [autoit][/autoit] [autoit]

    _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

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func OnEraseBkGnd($hwnd, $message, $wParam, $lParam)
    Local $rcClient
    Local $hObjOld
    Local $rcRight, $rcBottom
    Local $bmWidth, $bmHeight
    Local $bm = DllStructCreate($BITMAP)

    [/autoit] [autoit][/autoit] [autoit]

    If (Not $hbmp) Then Return 1

    [/autoit] [autoit][/autoit] [autoit]

    ; get the window's client area
    $rcClient = _WinAPI_GetClientRect($hwnd)

    [/autoit] [autoit][/autoit] [autoit]

    $rcRight = DllStructGetData($rcClient, "Right")
    $rcBottom = DllStructGetData($rcClient, "Bottom")

    [/autoit] [autoit][/autoit] [autoit]

    ; get the bitmap dimensions
    _WinAPI_GetObject($hbmp, DllStructGetSize($bm), DllStructGetPtr($bm))

    [/autoit] [autoit][/autoit] [autoit]

    ; select the bitmap into the memory DC
    $hObjOld = _WinAPI_SelectObject($hdcMem, $hbmp)

    [/autoit] [autoit][/autoit] [autoit]

    $bmWidth = DllStructGetData($bm, "bmWidth")
    $bmHeight = DllStructGetData($bm, "bmHeight")

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    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)

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

    Return "GUI_RUNDEFMSG"
    EndFunc ;==>WM_SIZING

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _bild_in_gui_beenden()
    ; free resources
    _WinAPI_DeleteObject($hbmp)
    _WinAPI_DeleteDC($hdcMem)
    GUIDelete($hwnd)
    EndFunc ;==>_bild_in_gui_beenden

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _bildgroesse2($bildgroesse_pfad_dateiname)
    Local $array_bilder_1[3], $hImage3

    [/autoit] [autoit][/autoit] [autoit]

    ; Initialisiert (startet) Microsoft Windows GDI+
    _GDIPlus_Startup()

    [/autoit] [autoit][/autoit] [autoit]

    ; Lädt ein Bild
    $hImage3 = _GDIPlus_ImageLoadFromFile($bildgroesse_pfad_dateiname)

    [/autoit] [autoit][/autoit] [autoit]

    ; Erzeugt eine Kopie einer 24 bit Bitmap
    $array_bilder_1[1] = _GDIPlus_ImageGetWidth($hImage3)
    $array_bilder_1[2] = _GDIPlus_ImageGetHeight($hImage3)

    [/autoit] [autoit][/autoit] [autoit]

    ; Ressourcen freigeben
    _GDIPlus_ImageDispose($hImage3)

    [/autoit] [autoit][/autoit] [autoit]

    ; Gibt die durch Microsoft Windows GDI+ verwendeten Ressourcen wieder frei
    _GDIPlus_Shutdown()

    [/autoit] [autoit][/autoit] [autoit]

    Return $array_bilder_1
    EndFunc ;==>_bildgroesse

    [/autoit]
  • Ja, das geht ^^. Aber es sieht nicht besonders ansprechend aus...

    Spoiler anzeigen
    [autoit]

    #region ;************ Includes ************
    #include <ScreenCapture.au3>
    #include <WindowsConstants.au3>
    #include <GUIConstantsEx.au3>
    #endregion ;************ Includes ************

    [/autoit] [autoit][/autoit] [autoit]

    $bild = @TempDir & "\" & "bild.jpg"
    _ScreenCapture_Capture($bild)

    [/autoit] [autoit][/autoit] [autoit]

    Global $hGui = GUICreate("Test", 300, 300, -1, -1, $WS_OVERLAPPEDWINDOW)
    $pic = GUICtrlCreatePic("", 0, 0, 300, 300)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    _bild()
    GUIRegisterMsg($WM_SIZE, "_bild")

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _bild()
    $win = WinGetPos("Test", "")
    GUICtrlSetImage($pic, $bild)
    GUICtrlSetPos($pic, 0, 0, $win[2], $win[3])
    EndFunc ;==>_bild

    [/autoit]


    Alternativ könnte man natürlich GDI+ verwenden.Mit Doublebuffering sollte das zumindest nicht mehr so flackern. Aber vielleicht lässt sich das ja auch so beheben.

  • Ok, danke.
    Bin dank dir nun deutlich weitergekommen.
    Den Tip mit GDI habe ich auch umgesetzt.

    Spoiler anzeigen
    [autoit]

    #region ;************ Includes ************
    #include <eigen_bilder.au3>
    #include <WindowsConstants.au3>
    #include <ScreenCapture.au3>
    #include <GUIConstantsEx.au3>
    #endregion ;************ Includes ************

    [/autoit] [autoit][/autoit] [autoit]

    Global $breite_min, $breite_max, $hoehe_min, $hoehe_max, $array_bilder_1[3], $hBitmap_quelle, $hGfxCtxt, $hHBitmap, $hImage, $breite = 800

    [/autoit] [autoit][/autoit] [autoit]

    Global $bild = @TempDir & "\" & "bild.jpg"
    _ScreenCapture_Capture($bild)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()
    Global $hImage2 = _GDIPlus_ImageLoadFromFile($bild)
    $array_bilder_1[1] = _GDIPlus_ImageGetWidth($hImage2)
    $array_bilder_1[2] = _GDIPlus_ImageGetHeight($hImage2)
    _GDIPlus_ImageDispose($hImage2)
    _GDIPlus_Shutdown()

    [/autoit] [autoit][/autoit] [autoit]

    Global $seitenverhaeltnis = $array_bilder_1[1] / $array_bilder_1[2]
    Global $hGui = GUICreate("Test", $breite, $breite / $seitenverhaeltnis, -1, -1, $WS_OVERLAPPEDWINDOW, $WS_EX_COMPOSITED)
    Global $pic = GUICtrlCreatePic("", 0, 0, $breite, $breite / $seitenverhaeltnis)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()
    _bild()
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    Func _bild()
    $hImage = _GDIPlus_ImageLoadFromFile($bild)
    Local $win = WinGetPos("Test", "")
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $win[2], "int", $win[3], "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
    $hBitmap_quelle = $aResult[6]
    $hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap_quelle)
    DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "handle", $hGfxCtxt, "int", 7)
    _GDIPlus_GraphicsDrawImageRect($hGfxCtxt, $hImage, 0, 0, $win[2], $win[3])
    $hHBitmap = _GDIPlus_BitmapCreateDIBFromBitmap($hBitmap_quelle)
    _WinAPI_DeleteObject(GUICtrlSendMsg($pic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap))
    GUICtrlSetPos($pic, Default, Default, $win[2], $win[3])
    EndFunc ;==>_bild

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global $aWS = WinGetPos($hGui)
    Global Const $ratio = $aWS[3] / $aWS[2]
    $breite_min = 0
    $breite_max = 9300
    $hoehe_min = 0
    $hoehe_max = 9300

    [/autoit] [autoit][/autoit] [autoit]

    _bild()
    GUIRegisterMsg($WM_SIZE, "_bild")
    GUIRegisterMsg($WM_SIZING, "WM_SIZING")
    GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO")

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    Sleep(10)
    WEnd
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_BitmapDispose($hBitmap_quelle)
    _GDIPlus_GraphicsDispose($hGfxCtxt)
    _WinAPI_DeleteObject(GUICtrlSendMsg($pic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap))
    _GDIPlus_Shutdown()

    [/autoit] [autoit][/autoit] [autoit]

    Func WM_GETMINMAXINFO($hWnd, $Msg, $wParam, $lParam)
    Local $minmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
    DllStructSetData($minmaxinfo, 7, $breite_min) ; min X
    DllStructSetData($minmaxinfo, 8, $hoehe_min) ; min Y
    DllStructSetData($minmaxinfo, 9, $breite_max) ; max X
    DllStructSetData($minmaxinfo, 10, $hoehe_max) ; max Y
    Return "GUI_RUNDEFMSG"
    EndFunc ;==>WM_GETMINMAXINFO

    [/autoit] [autoit][/autoit] [autoit]

    Func WM_SIZING($hWnd, $iMsg, $wParam, $lParam)
    Local $sRect = DllStructCreate("Int[4]", $lParam)
    Local $left = DllStructGetData($sRect, 1, 1)
    Local $top = DllStructGetData($sRect, 1, 2)
    Local $right = DllStructGetData($sRect, 1, 3)
    Local $bottom = DllStructGetData($sRect, 1, 4)

    [/autoit] [autoit][/autoit] [autoit]

    Switch $wParam ;drag side or corner
    Case 1, 2, 4, 7
    Local $iNewY = Int(($right - $left) * $ratio)
    DllStructSetData($sRect, 1, DllStructGetData($sRect, 1, 2) + $iNewY, 4)
    Case Else
    Local $iNewX = Int(($bottom - $top) / $ratio)
    DllStructSetData($sRect, 1, DllStructGetData($sRect, 1, 1) + $iNewX, 3)
    EndSwitch
    Return "GUI_RUNDEFMSG"
    EndFunc ;==>WM_SIZING

    [/autoit]

    Leider wird nicht das komplette Bild dargestellt.
    Je nachdem wie groß ich die GUI mache fehlt mal mehr mal weniger.

    Wie kann ich es sicherstellen, dass immer genau das komplette Bild sichtbar ist :?:

  • Das mit GDI+ verbessert zwar die Interpolation, aber das Flackern kommt vom Pic Control. Ich weiß nicht ob man das irgendwie verhindern kann. :S
    Ich bin mal dein Script durchgegangen und hab einige Kleinigkeiten verbessert und auch das Problem mit der Darstellungsgröße behoben. WinGetPos ist eine sehr unzuverlässige Methode um die Fenstergröße auszulesen -> ersetzt durch WinGetClientArea.

    Spoiler anzeigen
    [autoit]

    #region ;************ Includes ************
    ;~ #include <eigen_bilder.au3>
    #include <WindowsConstants.au3>
    #include <ScreenCapture.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #endregion ;************ Includes ************

    [/autoit] [autoit][/autoit] [autoit]

    Global $breite_min, $breite_max, $hoehe_min, $hoehe_max, $array_bilder_1[3], $hBitmap_quelle, $hGfxCtxt, $hHBitmap, $hImage, $breite = 800

    [/autoit] [autoit][/autoit] [autoit]

    Global $bild = @TempDir & "\" & "bild.jpg"
    _ScreenCapture_Capture($bild)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()
    Global $hImage = _GDIPlus_ImageLoadFromFile($bild)
    $array_bilder_1[1] = _GDIPlus_ImageGetWidth($hImage)
    $array_bilder_1[2] = _GDIPlus_ImageGetHeight($hImage)

    [/autoit] [autoit][/autoit] [autoit]

    Global $seitenverhaeltnis = $array_bilder_1[1] / $array_bilder_1[2]

    [/autoit] [autoit][/autoit] [autoit]

    Global $hGui = GUICreate("Test", $breite, $breite / $seitenverhaeltnis, -1, -1, $WS_OVERLAPPEDWINDOW, $WS_EX_COMPOSITED)
    Global $pic = GUICtrlCreatePic("", 0, 0, $breite, $breite / $seitenverhaeltnis)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    Global $aWS = WinGetClientSize($hGui)
    Global Const $ratio = $aWS[1] / $aWS[0]
    $breite_min = 0
    $breite_max = 9300
    $hoehe_min = 0
    $hoehe_max = 9300

    [/autoit] [autoit][/autoit] [autoit]

    _bild()
    GUIRegisterMsg($WM_SIZE, "_bild")
    GUIRegisterMsg($WM_SIZING, "WM_SIZING")
    GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO")

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    _WinAPI_DeleteObject(GUICtrlSendMsg($pic, 0x0172, 0, $hHBitmap))
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_BitmapDispose($hBitmap_quelle)
    _GDIPlus_GraphicsDispose($hGfxCtxt)
    _GDIPlus_Shutdown()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _bild()
    Local $win = WinGetClientSize($hGui)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $win[0], "int", $win[1], "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
    $hBitmap_quelle = $aResult[6]
    $hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap_quelle)
    DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "handle", $hGfxCtxt, "int", 1)
    _GDIPlus_GraphicsDrawImageRect($hGfxCtxt, $hImage, 0, 0, $win[0], $win[1])
    $hHBitmap = _GDIPlus_BitmapCreateDIBFromBitmap($hBitmap_quelle)
    GUICtrlSetPos($pic, Default, Default, $win[0], $win[1])
    _WinAPI_DeleteObject(GUICtrlSendMsg($pic, 0x0172, 0, $hHBitmap))
    EndFunc ;==>_bild

    [/autoit] [autoit][/autoit] [autoit]

    Func WM_GETMINMAXINFO($hWnd, $Msg, $wParam, $lParam)
    Local $minmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
    DllStructSetData($minmaxinfo, 7, $breite_min) ; min X
    DllStructSetData($minmaxinfo, 8, $hoehe_min) ; min Y
    DllStructSetData($minmaxinfo, 9, $breite_max) ; max X
    DllStructSetData($minmaxinfo, 10, $hoehe_max) ; max Y
    Return "GUI_RUNDEFMSG"
    EndFunc ;==>WM_GETMINMAXINFO

    [/autoit] [autoit][/autoit] [autoit]

    Func WM_SIZING($hWnd, $iMsg, $wParam, $lParam)
    Local $sRect = DllStructCreate("Int[4]", $lParam)
    Local $left = DllStructGetData($sRect, 1, 1)
    Local $top = DllStructGetData($sRect, 1, 2)
    Local $right = DllStructGetData($sRect, 1, 3)
    Local $bottom = DllStructGetData($sRect, 1, 4)

    [/autoit] [autoit][/autoit] [autoit]

    Switch $wParam ;drag side or corner
    Case 1, 2, 4, 7
    Local $iNewY = Int(($right - $left) * $ratio)
    DllStructSetData($sRect, 1, DllStructGetData($sRect, 1, 2) + $iNewY, 4)
    Case Else
    Local $iNewX = Int(($bottom - $top) / $ratio)
    DllStructSetData($sRect, 1, DllStructGetData($sRect, 1, 1) + $iNewX, 3)
    EndSwitch
    Return "GUI_RUNDEFMSG"
    EndFunc ;==>WM_SIZING

    [/autoit] [autoit][/autoit] [autoit]

    Func _GDIPlus_BitmapCreateDIBFromBitmap($hBitmap)
    Local $tBIHDR, $Ret, $tData, $pBits, $hResult = 0
    $Ret = DllCall($ghGDIPDll, 'uint', 'GdipGetImageDimension', 'ptr', $hBitmap, 'float*', 0, 'float*', 0)
    If (@error) Or ($Ret[0]) Then Return 0
    $tData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $Ret[2], $Ret[3], $GDIP_ILMREAD, $GDIP_PXF32ARGB)
    $pBits = DllStructGetData($tData, 'Scan0')
    If Not $pBits Then Return 0
    $tBIHDR = DllStructCreate('dword;long;long;ushort;ushort;dword;dword;long;long;dword;dword')
    DllStructSetData($tBIHDR, 1, DllStructGetSize($tBIHDR))
    DllStructSetData($tBIHDR, 2, $Ret[2])
    DllStructSetData($tBIHDR, 3, $Ret[3])
    DllStructSetData($tBIHDR, 4, 1)
    DllStructSetData($tBIHDR, 5, 32)
    DllStructSetData($tBIHDR, 6, 0)
    $hResult = DllCall('gdi32.dll', 'ptr', 'CreateDIBSection', 'hwnd', 0, 'ptr', DllStructGetPtr($tBIHDR), 'uint', 0, 'ptr*', 0, 'ptr', 0, 'dword', 0)
    If (Not @error) And ($hResult[0]) Then
    DllCall('gdi32.dll', 'dword', 'SetBitmapBits', 'ptr', $hResult[0], 'dword', $Ret[2] * $Ret[3] * 4, 'ptr', DllStructGetData($tData, 'Scan0'))
    $hResult = $hResult[0]
    Else
    $hResult = 0
    EndIf
    _GDIPlus_BitmapUnlockBits($hBitmap, $tData)
    Return $hResult
    EndFunc ;==>_GDIPlus_BitmapCreateDIBFromBitmap

    [/autoit]


    Leider musste ich dein vorheriges Konzept ein wenig durcheinander bringen, da bei mir das Script sonst nicht lauffähig war. Das solltest du aber ohne Probleme wieder rückgängig machen können.

  • Moin,

    so soll es aussehen (natürlich ohne "geflicker" und mit Bitmaps):

    Spoiler anzeigen
    [autoit]

    #include <WindowsConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <Constants.au3>
    #include <WinAPI.au3>

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; --- $BITMAP
    Global Const $BITMAP = _
    "LONG bmType;"& _
    "LONG bmWidth;"& _
    "LONG bmHeight;"& _
    "LONG bmWidthBytes;"& _
    "WORD bmPlanes;"& _
    "WORD bmBitsPixel;"& _
    "PTR bmBits;"

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global Const $HWND_DESKTOP = 0
    Global $sImagePath = "C:\Windows\System32\oobe\background.bmp"
    Global $hbmp, $hdcMem

    [/autoit] [autoit][/autoit] [autoit]

    ; start the main procedure
    Call ("_AuMain")

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _AuMain ( )

    [/autoit] [autoit][/autoit] [autoit]

    Local $hwnd

    [/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg ($WM_CREATE, "OnCreate")
    GUIRegisterMsg ($WM_ERASEBKGND, "OnEraseBkGnd")

    [/autoit] [autoit][/autoit] [autoit]

    $hwnd = GUICreate ("Test", 300, 300, -1, -1, $WS_OVERLAPPEDWINDOW)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState (@SW_SHOW, $hwnd)

    [/autoit] [autoit][/autoit] [autoit]

    While (TRUE)
    Switch GUIGetMsg (FALSE)
    Case $GUI_EVENT_CLOSE
    ExitLoop
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    ; free resources
    _WinAPI_DeleteObject ($hbmp)
    _WinAPI_DeleteDC ($hdcMem)

    [/autoit] [autoit][/autoit] [autoit]

    Return 0

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func OnCreate ($hwnd, $message, $wParam, $lParam)

    [/autoit] [autoit][/autoit] [autoit]

    Local $hdc

    [/autoit] [autoit][/autoit] [autoit]

    $hbmp = _WinAPI_LoadImage (0, $sImagePath, $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)

    [/autoit] [autoit][/autoit] [autoit]

    If (not $hbmp) Then
    ; error handling here
    ConsoleWrite (StringFormat ("_WinAPI_LoadImage fehlgeschlagen!\n"))
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $hdc = _WinAPI_GetDC ($HWND_DESKTOP)
    $hdcMem = _WinAPI_CreateCompatibleDC ($hdc)
    _WinAPI_ReleaseDC ($HWND_DESKTOP, $hdc)

    [/autoit] [autoit][/autoit] [autoit]

    If (not $hdcMem) Then
    ; error handling here
    ConsoleWrite (StringFormat ("_WinAPI_CreateCompatibleDC fehlgeschlagen!\n"))
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Return $GUI_RUNDEFMSG

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func OnEraseBkGnd ($hwnd, $message, $wParam, $lParam)

    [/autoit] [autoit][/autoit] [autoit]

    Local $rcClient
    Local $hObjOld
    Local $rcRight, $rcBottom
    Local $bmWidth , $bmHeight
    Local $bm = DllStructCreate ($BITMAP)

    [/autoit] [autoit][/autoit] [autoit]

    If (not $hbmp) Then
    Return 1
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ; get the window's client area
    $rcClient = _WinAPI_GetClientRect ($hwnd)

    [/autoit] [autoit][/autoit] [autoit]

    $rcRight = DllStructGetData ($rcClient, "Right")
    $rcBottom = DllStructGetData ($rcClient, "Bottom")

    [/autoit] [autoit][/autoit] [autoit]

    ; get the bitmap dimensions
    _WinAPI_GetObject ($hbmp, DllStructGetSize ($bm), DllStructGetPtr ($bm))

    [/autoit] [autoit][/autoit] [autoit]

    ; select the bitmap into the memory DC
    $hObjOld = _WinAPI_SelectObject ($hdcMem, $hbmp)

    [/autoit] [autoit][/autoit] [autoit]

    $bmWidth = DllStructGetData ($bm, "bmWidth")
    $bmHeight = DllStructGetData ($bm, "bmHeight")

    [/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

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func StretchBlt ($hdcDest, $nXOriginDest, $nYOriginDest, $nWidthDest, $nHeightDest, $hdcSrc, $nXOriginSrc, $nYOriginSrc, $nWidthSrc, $nHeightSrc, $dwRop)

    [/autoit] [autoit][/autoit] [autoit]

    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]

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit]

    Gruß
    Greenhorn


    Einmal editiert, zuletzt von Greenhorn (10. November 2012 um 23:26)

  • Da ich keine Lust hab die Header Files zu durchsuchen, hab ich mal einige Integer für den StretchBltMode ausprobiert. 4 scheint die besten Resultate für Bilder zu liefern.

    Spoiler anzeigen
    [autoit]

    #include <WindowsConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <Constants.au3>
    #include <WinAPI.au3>

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; --- $BITMAP
    Global Const $BITMAP = _
    "LONG bmType;"& _
    "LONG bmWidth;"& _
    "LONG bmHeight;"& _
    "LONG bmWidthBytes;"& _
    "WORD bmPlanes;"& _
    "WORD bmBitsPixel;"& _
    "PTR bmBits;"

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global Const $HWND_DESKTOP = 0
    Global $sImagePath = "C:\Windows\System32\oobe\background.bmp"
    Global $hbmp, $hdcMem

    [/autoit] [autoit][/autoit] [autoit]

    ; start the main procedure
    Call ("_AuMain")

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _AuMain ( )

    [/autoit] [autoit][/autoit] [autoit]

    Local $hwnd

    [/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg ($WM_CREATE, "OnCreate")
    GUIRegisterMsg ($WM_ERASEBKGND, "OnEraseBkGnd")

    [/autoit] [autoit][/autoit] [autoit]

    $hwnd = GUICreate ("Test", 300, 300, -1, -1, $WS_OVERLAPPEDWINDOW)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState (@SW_SHOW, $hwnd)

    [/autoit] [autoit][/autoit] [autoit]

    While (TRUE)
    Switch GUIGetMsg (FALSE)
    Case $GUI_EVENT_CLOSE
    ExitLoop
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    ; free resources
    _WinAPI_DeleteObject ($hbmp)
    _WinAPI_DeleteDC ($hdcMem)

    [/autoit] [autoit][/autoit] [autoit]

    Return 0

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func OnCreate ($hwnd, $message, $wParam, $lParam)

    [/autoit] [autoit][/autoit] [autoit]

    Local $hdc

    [/autoit] [autoit][/autoit] [autoit]

    $hbmp = _WinAPI_LoadImage (0, $sImagePath, $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)

    [/autoit] [autoit][/autoit] [autoit]

    If (not $hbmp) Then
    ; error handling here
    ConsoleWrite (StringFormat ("_WinAPI_LoadImage fehlgeschlagen!\n"))
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $hdc = _WinAPI_GetDC ($HWND_DESKTOP)
    $hdcMem = _WinAPI_CreateCompatibleDC ($hdc)

    [/autoit] [autoit][/autoit] [autoit]

    _WinAPI_ReleaseDC ($HWND_DESKTOP, $hdc)

    [/autoit] [autoit][/autoit] [autoit]

    If (not $hdcMem) Then
    ; error handling here
    ConsoleWrite (StringFormat ("_WinAPI_CreateCompatibleDC fehlgeschlagen!\n"))
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Return $GUI_RUNDEFMSG

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func OnEraseBkGnd ($hwnd, $message, $wParam, $lParam)

    [/autoit] [autoit][/autoit] [autoit]

    Local $rcClient
    Local $hObjOld
    Local $rcRight, $rcBottom
    Local $bmWidth , $bmHeight
    Local $bm = DllStructCreate ($BITMAP)

    [/autoit] [autoit][/autoit] [autoit]

    If (not $hbmp) Then
    Return 1
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ; get the window's client area
    $rcClient = _WinAPI_GetClientRect ($hwnd)

    [/autoit] [autoit][/autoit] [autoit]

    $rcRight = DllStructGetData ($rcClient, "Right")
    $rcBottom = DllStructGetData ($rcClient, "Bottom")

    [/autoit] [autoit][/autoit] [autoit]

    ; get the bitmap dimensions
    _WinAPI_GetObject ($hbmp, DllStructGetSize ($bm), DllStructGetPtr ($bm))

    [/autoit] [autoit][/autoit] [autoit]

    ; select the bitmap into the memory DC
    $hObjOld = _WinAPI_SelectObject ($hdcMem, $hbmp)

    [/autoit] [autoit][/autoit] [autoit]

    $bmWidth = DllStructGetData ($bm, "bmWidth")
    $bmHeight = DllStructGetData ($bm, "bmHeight")

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func StretchBlt ($hdcDest, $nXOriginDest, $nYOriginDest, $nWidthDest, $nHeightDest, $hdcSrc, $nXOriginSrc, $nYOriginSrc, $nWidthSrc, $nHeightSrc, $dwRop)

    [/autoit] [autoit][/autoit] [autoit]

    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]

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit]
  • Wow, das sieht nochmal besser aus. 8o
    Danke schonmal ihr beiden :thumbup:

    Spoiler anzeigen
    [autoit]

    #region ;************ Includes ************
    #include <ScreenCapture.au3>;~~~
    #include <WinAPI.au3>;~~~
    #include <WindowsConstants.au3>;~~~
    #include <GUIConstantsEx.au3>;~~~
    #include <Constants.au3>
    #endregion ;************ Includes ************

    [/autoit] [autoit][/autoit] [autoit]

    Global $array_bilder_1[3], $breite = 800
    Global $hbmp, $hdcMem

    [/autoit] [autoit][/autoit] [autoit]

    ; --- $BITMAP
    Global Const $BITMAP = _
    "LONG bmType;" & _
    "LONG bmWidth;" & _
    "LONG bmHeight;" & _
    "LONG bmWidthBytes;" & _
    "WORD bmPlanes;" & _
    "WORD bmBitsPixel;" & _
    "PTR bmBits;"

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global Const $HWND_DESKTOP = 0
    Global $sImagePath = @TempDir & "\" & "bild.bmp"
    _ScreenCapture_Capture($sImagePath)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()
    Global $hImage = _GDIPlus_ImageLoadFromFile($sImagePath)
    $array_bilder_1[1] = _GDIPlus_ImageGetWidth($hImage)
    $array_bilder_1[2] = _GDIPlus_ImageGetHeight($hImage)

    [/autoit] [autoit][/autoit] [autoit]

    Global $seitenverhaeltnis = $array_bilder_1[1] / $array_bilder_1[2]
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_Shutdown()

    [/autoit] [autoit][/autoit] [autoit]

    _AuMain()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _AuMain()
    Local $hwnd

    [/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_CREATE, "OnCreate")
    GUIRegisterMsg($WM_ERASEBKGND, "OnEraseBkGnd")
    GUIRegisterMsg($WM_SIZING, "WM_SIZING")
    GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO")

    [/autoit] [autoit][/autoit] [autoit]

    $hwnd = GUICreate("Test", $breite, $breite / $seitenverhaeltnis, -1, -1, $WS_OVERLAPPEDWINDOW)

    [/autoit] [autoit][/autoit] [autoit]

    Global $aWS = WinGetClientSize($hwnd)
    Global Const $ratio = $aWS[1] / $aWS[0]
    Global $breite_min = 0
    Global $breite_max = 9300
    Global $hoehe_min = 0
    Global $hoehe_max = 9300

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState(@SW_SHOW, $hwnd)

    [/autoit] [autoit][/autoit] [autoit]

    While (True)
    Switch GUIGetMsg(False)
    Case $GUI_EVENT_CLOSE
    ExitLoop
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    ; free resources
    _WinAPI_DeleteObject($hbmp)
    _WinAPI_DeleteDC($hdcMem)

    [/autoit] [autoit][/autoit] [autoit]

    Return 0
    EndFunc ;==>_AuMain

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func OnCreate($hwnd, $message, $wParam, $lParam)
    Local $hdc

    [/autoit] [autoit][/autoit] [autoit]

    $hbmp = _WinAPI_LoadImage(0, $sImagePath, $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)

    [/autoit] [autoit][/autoit] [autoit]

    If (Not $hbmp) Then
    ; error handling here
    ConsoleWrite(StringFormat("_WinAPI_LoadImage fehlgeschlagen!\n"))
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $hdc = _WinAPI_GetDC($HWND_DESKTOP)
    $hdcMem = _WinAPI_CreateCompatibleDC($hdc)

    [/autoit] [autoit][/autoit] [autoit]

    _WinAPI_ReleaseDC($HWND_DESKTOP, $hdc)

    [/autoit] [autoit][/autoit] [autoit]

    If (Not $hdcMem) Then
    ; error handling here
    ConsoleWrite(StringFormat("_WinAPI_CreateCompatibleDC fehlgeschlagen!\n"))
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Return $GUI_RUNDEFMSG
    EndFunc ;==>OnCreate

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func OnEraseBkGnd($hwnd, $message, $wParam, $lParam)
    Local $rcClient
    Local $hObjOld
    Local $rcRight, $rcBottom
    Local $bmWidth, $bmHeight
    Local $bm = DllStructCreate($BITMAP)

    [/autoit] [autoit][/autoit] [autoit]

    If (Not $hbmp) Then
    Return 1
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ; get the window's client area
    $rcClient = _WinAPI_GetClientRect($hwnd)

    [/autoit] [autoit][/autoit] [autoit]

    $rcRight = DllStructGetData($rcClient, "Right")
    $rcBottom = DllStructGetData($rcClient, "Bottom")

    [/autoit] [autoit][/autoit] [autoit]

    ; get the bitmap dimensions
    _WinAPI_GetObject($hbmp, DllStructGetSize($bm), DllStructGetPtr($bm))

    [/autoit] [autoit][/autoit] [autoit]

    ; select the bitmap into the memory DC
    $hObjOld = _WinAPI_SelectObject($hdcMem, $hbmp)

    [/autoit] [autoit][/autoit] [autoit]

    $bmWidth = DllStructGetData($bm, "bmWidth")
    $bmHeight = DllStructGetData($bm, "bmHeight")

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func WM_GETMINMAXINFO($hwnd, $Msg, $wParam, $lParam)
    Local $minmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
    DllStructSetData($minmaxinfo, 7, $breite_min) ; min X
    DllStructSetData($minmaxinfo, 8, $hoehe_min) ; min Y
    DllStructSetData($minmaxinfo, 9, $breite_max) ; max X
    DllStructSetData($minmaxinfo, 10, $hoehe_max) ; max Y
    Return "GUI_RUNDEFMSG"
    EndFunc ;==>WM_GETMINMAXINFO

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func WM_SIZING($hwnd, $iMsg, $wParam, $lParam)
    Local $sRect = DllStructCreate("Int[4]", $lParam)
    Local $left = DllStructGetData($sRect, 1, 1)
    Local $top = DllStructGetData($sRect, 1, 2)
    Local $right = DllStructGetData($sRect, 1, 3)
    Local $bottom = DllStructGetData($sRect, 1, 4)

    [/autoit] [autoit][/autoit] [autoit]

    Switch $wParam ;drag side or corner
    Case 1, 2, 4, 7
    Local $iNewY = Int(($right - $left) * $ratio)
    DllStructSetData($sRect, 1, DllStructGetData($sRect, 1, 2) + $iNewY, 4)
    Case Else
    Local $iNewX = Int(($bottom - $top) / $ratio)
    DllStructSetData($sRect, 1, DllStructGetData($sRect, 1, 1) + $iNewX, 3)
    EndSwitch
    Return "GUI_RUNDEFMSG"
    EndFunc ;==>WM_SIZING

    [/autoit]

    2 Kleinere Problemchen habe ich.

    Wenn die Gui zum ändern der Größe unten rechts angeklickt wird, so springt diese etwas in die Breite.

    Wenn die Gui ganz klein gezogen wird, stimmt das Seitenverhältnis nicht mehr.

  • Ich hab noch ein paar kleine Verbeserungen hinzugefügt.

    Spoiler anzeigen
    [autoit]

    #region ;************ Includes ************
    #include <ScreenCapture.au3>;~~~
    #include <WinAPI.au3>;~~~
    #include <WindowsConstants.au3>;~~~
    #include <GUIConstantsEx.au3>;~~~
    #include <Constants.au3>
    #endregion ;************ Includes ************

    [/autoit] [autoit][/autoit] [autoit]

    Global $iGUI_WidthInitial = 800, $fRatio, $iMinWidth = 0, $iMinHeight = 0, $iMaxWidth = 9300, $iMaxHeight = 9300
    Global $hbmp, $hdcMem

    [/autoit] [autoit][/autoit] [autoit]

    ; --- $BITMAP
    Global Const $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()

    [/autoit] [autoit][/autoit] [autoit]

    $fRatio = _WinAPI_GetClientWidth($HWND_DESKTOP) / _WinAPI_GetClientHeight($HWND_DESKTOP)
    ConsoleWrite("Original Ratio: " & $fRatio & @CRLF)

    [/autoit] [autoit][/autoit] [autoit]

    _AuMain()

    [/autoit] [autoit][/autoit] [autoit]

    Func _AuMain()
    Local $hwnd

    [/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_CREATE, "OnCreate")
    GUIRegisterMsg($WM_ERASEBKGND, "OnEraseBkGnd")
    GUIRegisterMsg($WM_SIZING, "WM_SIZING")
    GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO")

    [/autoit] [autoit][/autoit] [autoit]

    $hwnd = GUICreate("Test", $iGUI_WidthInitial, $iGUI_WidthInitial / $fRatio, -1, -1, $WS_OVERLAPPEDWINDOW)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    While True
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    ExitLoop
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    ; free resources
    _WinAPI_DeleteObject($hbmp)
    _WinAPI_DeleteDC($hdcMem)

    [/autoit] [autoit][/autoit] [autoit]

    Return 0
    EndFunc ;==>_AuMain

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func OnCreate($hwnd, $message, $wParam, $lParam)
    Local $hdc, $bm = DllStructCreate($BITMAP)

    [/autoit] [autoit][/autoit] [autoit]

    $hbmp = _ScreenCapture_Capture()

    [/autoit] [autoit][/autoit] [autoit]

    If (Not $hbmp) Then
    ; error handling here
    ConsoleWrite(StringFormat("_WinAPI_LoadImage fehlgeschlagen!\n"))
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $hdc = _WinAPI_GetDC($HWND_DESKTOP)
    $hdcMem = _WinAPI_CreateCompatibleDC($hdc)

    [/autoit] [autoit][/autoit] [autoit]

    _WinAPI_ReleaseDC($HWND_DESKTOP, $hdc)

    [/autoit] [autoit][/autoit] [autoit]

    If (Not $hdcMem) Then
    ; error handling here
    ConsoleWrite(StringFormat("_WinAPI_CreateCompatibleDC fehlgeschlagen!\n"))
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Return $GUI_RUNDEFMSG
    EndFunc ;==>OnCreate

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func OnEraseBkGnd($hwnd, $message, $wParam, $lParam)
    Local $rcClient
    Local $hObjOld
    Local $rcRight, $rcBottom
    Local $bmWidth, $bmHeight
    Local $bm = DllStructCreate($BITMAP)

    [/autoit] [autoit][/autoit] [autoit]

    If (Not $hbmp) Then
    Return 1
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ; get the window's client area
    $rcClient = _WinAPI_GetClientRect($hwnd)

    [/autoit] [autoit][/autoit] [autoit]

    $rcRight = DllStructGetData($rcClient, "Right")
    $rcBottom = DllStructGetData($rcClient, "Bottom")
    ConsoleWrite("Ratio after WM_SIZING " & $rcRight / $rcBottom & @CRLF)

    [/autoit] [autoit][/autoit] [autoit]

    ; get the bitmap dimensions
    _WinAPI_GetObject($hbmp, DllStructGetSize($bm), DllStructGetPtr($bm))

    [/autoit] [autoit][/autoit] [autoit]

    ; select the bitmap into the memory DC
    $hObjOld = _WinAPI_SelectObject($hdcMem, $hbmp)

    [/autoit] [autoit][/autoit] [autoit]

    $bmWidth = DllStructGetData($bm, "bmWidth")
    $bmHeight = DllStructGetData($bm, "bmHeight")

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func WM_SIZING($hwnd, $iMsg, $wParam, $lParam)
    Local $sRect = DllStructCreate("Int[4]", $lParam)
    Local $left = DllStructGetData($sRect, 1, 1)
    Local $top = DllStructGetData($sRect, 1, 2)
    Local $right = DllStructGetData($sRect, 1, 3)
    Local $bottom = DllStructGetData($sRect, 1, 4)

    [/autoit] [autoit][/autoit] [autoit]

    Switch $wParam ;drag side or corner
    Case 1, 2, 4, 7
    Local $iNewY = Int(($right - $left) / $fRatio)
    DllStructSetData($sRect, 1, $top + $iNewY, 4)
    Case Else
    Local $iNewX = Int(($bottom - $top) * $fRatio)
    DllStructSetData($sRect, 1, $left + $iNewX, 3)
    EndSwitch

    [/autoit] [autoit][/autoit] [autoit]

    Return "GUI_RUNDEFMSG"
    EndFunc ;==>WM_SIZING

    [/autoit]


    Ich kann zwar vermuten welcher Teil diese falsche Fenstergröße verursacht, aber ich weiß nicht wieso das passiert. Bei WM_SIZING werden zwar die korrekten Werte berechet, aber sie werden nicht als Fenstergröße übernommen. Schau dir mal die Konsolenausgabe von diesem Script an, dann siehst du was ich meine.

  • Hm, stimmt das Verhältnis ändert sich ständig.
    Hat dies was mit dem Rahmen der GUI zu tun.
    Wird der nicht berücksichtigt?

  • Ganz klar ist es mir immer noch nicht, welche Koordinaten bei WM_SIZING nun verwendet werden.. Zumindest klappt es so:

    Spoiler anzeigen
    [autoit]

    #include <WindowsConstants.au3>
    #include <GUIConstants.au3>
    #include <Constants.au3>
    #include <WinAPI.au3>
    #include <ScreenCapture.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global $iGUI_WidthInitial = 800, $fRatio, $iMinWidth = 0, $iMinHeight = 0, $iMaxWidth = 9300, $iMaxHeight = 9300, $iX_Offset, $iY_Offset
    Global $hbmp, $hdcMem

    [/autoit] [autoit][/autoit] [autoit]

    ; --- $BITMAP
    Global Const $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()

    [/autoit] [autoit][/autoit] [autoit]

    $fRatio = _WinAPI_GetClientWidth($HWND_DESKTOP) / _WinAPI_GetClientHeight($HWND_DESKTOP)

    [/autoit] [autoit][/autoit] [autoit]

    _AuMain()

    [/autoit] [autoit][/autoit] [autoit]

    Func _AuMain()
    Local $hwnd

    [/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_CREATE, "OnCreate")
    GUIRegisterMsg($WM_ERASEBKGND, "OnEraseBkGnd")
    GUIRegisterMsg($WM_SIZING, "WM_SIZING")
    GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO")

    [/autoit] [autoit][/autoit] [autoit]

    $hwnd = GUICreate("Test", $iGUI_WidthInitial, Floor($iGUI_WidthInitial / $fRatio), -1, -1, $WS_OVERLAPPEDWINDOW)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    $fRatio = _WinAPI_GetWindowWidth($hwnd) / _WinAPI_GetWindowHeight($hwnd)

    [/autoit] [autoit][/autoit] [autoit]

    While True
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    ExitLoop
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    ; free resources
    _WinAPI_DeleteObject($hbmp)
    _WinAPI_DeleteDC($hdcMem)

    [/autoit] [autoit][/autoit] [autoit]

    Return 0
    EndFunc ;==>_AuMain

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func OnCreate($hwnd, $message, $wParam, $lParam)
    Local $hdc, $bm = DllStructCreate($BITMAP)

    [/autoit] [autoit][/autoit] [autoit]

    $hbmp = _ScreenCapture_Capture()

    [/autoit] [autoit][/autoit] [autoit]

    If (Not $hbmp) Then
    ; error handling here
    ConsoleWrite(StringFormat("_WinAPI_LoadImage fehlgeschlagen!\n"))
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $hdc = _WinAPI_GetDC($HWND_DESKTOP)
    $hdcMem = _WinAPI_CreateCompatibleDC($hdc)

    [/autoit] [autoit][/autoit] [autoit]

    _WinAPI_ReleaseDC($HWND_DESKTOP, $hdc)

    [/autoit] [autoit][/autoit] [autoit]

    If (Not $hdcMem) Then
    ; error handling here
    ConsoleWrite(StringFormat("_WinAPI_CreateCompatibleDC fehlgeschlagen!\n"))
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Return $GUI_RUNDEFMSG
    EndFunc ;==>OnCreate

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func OnEraseBkGnd($hwnd, $message, $wParam, $lParam)
    Local $rcClient
    Local $hObjOld
    Local $rcRight, $rcBottom
    Local $bmWidth, $bmHeight
    Local $bm = DllStructCreate($BITMAP)

    [/autoit] [autoit][/autoit] [autoit]

    If (Not $hbmp) Then
    Return 1
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ; get the window's client area
    $rcClient = _WinAPI_GetClientRect($hwnd)

    [/autoit] [autoit][/autoit] [autoit]

    $rcRight = DllStructGetData($rcClient, "Right")
    $rcBottom = DllStructGetData($rcClient, "Bottom")

    [/autoit] [autoit][/autoit] [autoit]

    ; get the bitmap dimensions
    _WinAPI_GetObject($hbmp, DllStructGetSize($bm), DllStructGetPtr($bm))

    [/autoit] [autoit][/autoit] [autoit]

    ; select the bitmap into the memory DC
    $hObjOld = _WinAPI_SelectObject($hdcMem, $hbmp)

    [/autoit] [autoit][/autoit] [autoit]

    $bmWidth = DllStructGetData($bm, "bmWidth")
    $bmHeight = DllStructGetData($bm, "bmHeight")

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func WM_SIZING($hwnd, $iMsg, $wParam, $lParam)
    Local $tRect_Cur = DllStructCreate("int[4]", $lParam), $tRect_New = DllStructCreate($tagRECT)
    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)

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

    Return "GUI_RUNDEFMSG"
    EndFunc ;==>WM_SIZING

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _WinAPI_AdjustWindowRectEx
    ; Description....: Calculates the required size of the window rectangle, based on the desired size of the client rectangle.
    ; Syntax.........: _WinAPI_AdjustWindowRectEx ( ByRef $tRECT, $iStyle [, $iExStyle [, $fMenu] )
    ; Parameters.....: $tRECT - $tagRECT structure that contains the coordinates of the desired client area.
    ; $iStyle - The window style of the window whose required size is to be calculated. Note that you cannot
    ; specify the $WS_OVERLAPPED style.
    ; $iExStyle - The extended window style of the window whose required size is to be calculated.
    ; $fMenu - Specifies whether the window has a menu, valid values:
    ; |TRUE - The window has a menu, valid values:
    ; |FALSE - The window does not has a menu. (Default)
    ; Return values..: Success - 1.
    ; Failure - 0 and sets the @error flag to non-zero.
    ; Author.........: Yashied
    ; Modified.......:
    ; Remarks........: None
    ; Related........:
    ; Link...........: @@MsdnLink@@ AdjustWindowRectEx
    ; Example........: Yes
    ; ===============================================================================================================================

    [/autoit] [autoit][/autoit] [autoit]

    Func _WinAPI_AdjustWindowRectEx(ByRef $tRECT, $iStyle, $iExStyle = 0, $fMenu = 0)

    [/autoit] [autoit][/autoit] [autoit]

    Local $Ret = DllCall('user32.dll', 'int', 'AdjustWindowRectEx', 'ptr', DllStructGetPtr($tRECT), 'dword', $iStyle, 'int', $fMenu, 'dword', $iExStyle)

    [/autoit] [autoit][/autoit] [autoit]

    If (@error) Or (Not $Ret[0]) Then
    Return SetError(1, 0, 0)
    EndIf
    Return 1
    EndFunc ;==>_WinAPI_AdjustWindowRectEx

    [/autoit]


    Ich hab jetzt in Zeile 37 eine Zuweisung ergänzt, die $fRatio auf das Seitenverhältnis vom gesamten Fenster setzt. Dann passt es nachher.

  • So, habe es nun noch so geändert, dass das Seitenverhältnis bei der min. und max. Größe auch immer beibehalten wird.

    Spoiler anzeigen
    [autoit]

    #Region ;************ Includes ************
    #Include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <ScreenCapture.au3>
    #EndRegion ;************ Includes ************

    [/autoit] [autoit][/autoit] [autoit]

    Global $iGUI_WidthInitial = 800, $fRatio, $iMinWidth = 200, $iMinHeight, $iMaxWidth = 1300, $iMaxHeight
    Global $hbmp, $hdcMem

    [/autoit] [autoit][/autoit] [autoit]

    Opt("GUIOnEventMode", 1) ; 0=ausgeschaltet, 1=OnEvent Modus aktiviert

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $BITMAP = "LONG bmType;" & "LONG bmWidth;" & "LONG bmHeight;" & "LONG bmWidthBytes;" & "WORD bmPlanes;" & "WORD bmBitsPixel;" & "PTR bmBits;"
    Global Const $HWND_DESKTOP = _WinAPI_GetDesktopWindow()

    [/autoit] [autoit][/autoit] [autoit]

    $fRatio = _WinAPI_GetClientWidth($HWND_DESKTOP) / _WinAPI_GetClientHeight($HWND_DESKTOP)

    [/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_CREATE, "OnCreate")
    GUIRegisterMsg($WM_ERASEBKGND, "OnEraseBkGnd")
    GUIRegisterMsg($WM_SIZING, "WM_SIZING")
    GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO")

    [/autoit] [autoit][/autoit] [autoit]

    Global $hwnd = GUICreate("Test", $iGUI_WidthInitial, Floor($iGUI_WidthInitial / $fRatio), -1, -1, $WS_OVERLAPPEDWINDOW)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    GUISetOnEvent($GUI_EVENT_CLOSE, "_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

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;Schleife
    While 1
    Sleep(10)
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func OnCreate($hwnd, $message, $wParam, $lParam)
    Local $hdc

    [/autoit] [autoit][/autoit] [autoit]

    $hbmp = _ScreenCapture_Capture()

    [/autoit] [autoit][/autoit] [autoit]

    If (Not $hbmp) Then ConsoleWrite(StringFormat("_WinAPI_LoadImage fehlgeschlagen!\n")); error handling here

    [/autoit] [autoit][/autoit] [autoit]

    $hdc = _WinAPI_GetDC($HWND_DESKTOP)
    $hdcMem = _WinAPI_CreateCompatibleDC($hdc)

    [/autoit] [autoit][/autoit] [autoit]

    _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

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func OnEraseBkGnd($hwnd, $message, $wParam, $lParam)
    Local $rcClient
    Local $hObjOld
    Local $rcRight, $rcBottom
    Local $bmWidth, $bmHeight
    Local $bm = DllStructCreate($BITMAP)

    [/autoit] [autoit][/autoit] [autoit]

    If (Not $hbmp) Then Return 1

    [/autoit] [autoit][/autoit] [autoit]

    ; get the window's client area
    $rcClient = _WinAPI_GetClientRect($hwnd)

    [/autoit] [autoit][/autoit] [autoit]

    $rcRight = DllStructGetData($rcClient, "Right")
    $rcBottom = DllStructGetData($rcClient, "Bottom")

    [/autoit] [autoit][/autoit] [autoit]

    ; get the bitmap dimensions
    _WinAPI_GetObject($hbmp, DllStructGetSize($bm), DllStructGetPtr($bm))

    [/autoit] [autoit][/autoit] [autoit]

    ; select the bitmap into the memory DC
    $hObjOld = _WinAPI_SelectObject($hdcMem, $hbmp)

    [/autoit] [autoit][/autoit] [autoit]

    $bmWidth = DllStructGetData($bm, "bmWidth")
    $bmHeight = DllStructGetData($bm, "bmHeight")

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    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)

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

    Return "GUI_RUNDEFMSG"
    EndFunc ;==>WM_SIZING

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _beenden()
    ; free resources
    _WinAPI_DeleteObject($hbmp)
    _WinAPI_DeleteDC($hdcMem)

    [/autoit] [autoit][/autoit] [autoit]

    Exit
    EndFunc ;==>_beenden

    [/autoit]
  • Muß den Thread doch nochmal aufmachen.

    Ich will als Quelle ein x-beliebiges jpg-Bild nehmen und das ganze in eine Funktion packen.
    Leider komme ich mit den ganzen _Winapi-Befehlen nicht klar.
    Ich hab mal das geändert was ist weiß.
    Probierts aus dann seht ihr wo die Fehlermeldungen kommen.

    Hoffe ihr könnt mir nochmal weiterhelfen.

    Spoiler anzeigen
    [autoit]

    #Region ;************ Includes ************
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <ScreenCapture.au3>
    #EndRegion ;************ Includes ************

    [/autoit] [autoit][/autoit] [autoit]

    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]

    [/autoit] [autoit][/autoit] [autoit]

    $iMinWidth = $iMinWidth_func
    $iMaxWidth = $iMaxWidth_func

    [/autoit] [autoit][/autoit] [autoit]

    $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]

    [/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_CREATE, "OnCreate")
    GUIRegisterMsg($WM_ERASEBKGND, "OnEraseBkGnd")
    GUIRegisterMsg($WM_SIZING, "WM_SIZING")
    GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO")

    [/autoit] [autoit][/autoit] [autoit]

    $hwnd = GUICreate($title_func, $iGUI_WidthInitial, Floor($iGUI_WidthInitial / $fRatio), -1, -1, $WS_OVERLAPPEDWINDOW)
    GUISetState(@SW_SHOW, $hwnd)

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

    ;Schleife
    While 1
    Sleep(10)
    WEnd
    EndFunc ;==>_bild_in_gui

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func OnCreate($hwnd, $message, $wParam, $lParam)
    Local $hdc

    [/autoit] [autoit][/autoit] [autoit]

    ;~ $hbmp = _ScreenCapture_Capture()
    ;~ If (Not $hbmp) Then ConsoleWrite(StringFormat("_WinAPI_LoadImage fehlgeschlagen!\n")); error handling here

    [/autoit] [autoit][/autoit] [autoit]

    $hdc = _WinAPI_GetDC($HWND_DESKTOP)
    $hdcMem = _WinAPI_CreateCompatibleDC($hdc)

    [/autoit] [autoit][/autoit] [autoit]

    _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

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func OnEraseBkGnd($hwnd, $message, $wParam, $lParam)
    Local $rcClient
    Local $hObjOld
    Local $rcRight, $rcBottom
    Local $bmWidth, $bmHeight
    Local $bm = DllStructCreate($BITMAP)

    [/autoit] [autoit][/autoit] [autoit]

    If (Not $hbmp) Then Return 1

    [/autoit] [autoit][/autoit] [autoit]

    ; get the window's client area
    $rcClient = _WinAPI_GetClientRect($hwnd)

    [/autoit] [autoit][/autoit] [autoit]

    $rcRight = DllStructGetData($rcClient, "Right")
    $rcBottom = DllStructGetData($rcClient, "Bottom")

    [/autoit] [autoit][/autoit] [autoit]

    ; get the bitmap dimensions
    _WinAPI_GetObject($hbmp, DllStructGetSize($bm), DllStructGetPtr($bm))

    [/autoit] [autoit][/autoit] [autoit]

    ; select the bitmap into the memory DC
    $hObjOld = _WinAPI_SelectObject($hdcMem, $hbmp)

    [/autoit] [autoit][/autoit] [autoit]

    $bmWidth = DllStructGetData($bm, "bmWidth")
    $bmHeight = DllStructGetData($bm, "bmHeight")

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    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)

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

    Return "GUI_RUNDEFMSG"
    EndFunc ;==>WM_SIZING

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _bild_in_gui_beenden()
    ; free resources
    _WinAPI_DeleteObject($hbmp)
    _WinAPI_DeleteDC($hdcMem)
    GUIDelete($hwnd)
    EndFunc ;==>_bild_in_gui_beenden

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _bildgroesse2($bildgroesse_pfad_dateiname)
    Local $array_bilder_1[3], $hImage3

    [/autoit] [autoit][/autoit] [autoit]

    ; Initialisiert (startet) Microsoft Windows GDI+
    _GDIPlus_Startup()

    [/autoit] [autoit][/autoit] [autoit]

    ; Lädt ein Bild
    $hImage3 = _GDIPlus_ImageLoadFromFile($bildgroesse_pfad_dateiname)

    [/autoit] [autoit][/autoit] [autoit]

    ; Erzeugt eine Kopie einer 24 bit Bitmap
    $array_bilder_1[1] = _GDIPlus_ImageGetWidth($hImage3)
    $array_bilder_1[2] = _GDIPlus_ImageGetHeight($hImage3)

    [/autoit] [autoit][/autoit] [autoit]

    ; Ressourcen freigeben
    _GDIPlus_ImageDispose($hImage3)

    [/autoit] [autoit][/autoit] [autoit]

    ; Gibt die durch Microsoft Windows GDI+ verwendeten Ressourcen wieder frei
    _GDIPlus_Shutdown()

    [/autoit] [autoit][/autoit] [autoit]

    Return $array_bilder_1
    EndFunc ;==>_bildgroesse

    [/autoit]
  • Ich habe nicht alle Beiträge gelesen und kann deshalb nicht sagen, ob so was ähnliches bereits gepostet wurde.

    Spoiler anzeigen
    [autoit]


    #include <Constants.au3>
    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $STM_SETIMAGE = 0x0172
    Global $sPathKey = "HKLM64\SOFTWARE\AutoIt v3\AutoIt\"
    If @OSArch = "x64" Then $sPathKey = "HKLM\SOFTWARE\Wow6432Node\AutoIt v3\AutoIt\"
    Global $sImage = RegRead($sPathKey, "InstallDir") & "\Examples\GUI\logo4.gif"

    [/autoit] [autoit][/autoit] [autoit]

    Global $hGUI = GUICreate("Test", 235, 112, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_THICKFRAME))
    Global $idPic = GUICtrlCreatePic("", 32, 16, 169, 68)
    GUICtrlSetResizing(-1, $GUI_DOCKVCENTER + $GUI_DOCKHCENTER)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()
    Global $hBmp = _GDIPlus_BitmapCreateFromFile($sImage)
    Global $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp)
    Global $hB = GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap)
    If $hB Then _WinAPI_DeleteObject($hB)
    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    _GDIPlus_BitmapDispose($hBmp)
    _GDIPlus_Shutdown()
    GUIDelete()
    Exit
    EndSwitch
    WEnd

    [/autoit]

    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯

  • Nein. Wurde noch nicht gepostet. Und irgendwie fühle ich mich deswegen gerade ein wenig dämlich ^^.
    Die Interpolation ist bei deinem Beispiel halt nicht so schön, aber ansonsten ist es einfacher. Tweaky müsste dann bloß noch sein WM_SIZING gedöns einbauen.

  • Du musst dich nicht dämlich fühlen, denn viele Wege führen nach Rom. Manchmal denke auch zu kompliziert, obwohl der Weg nach Rom viel einfachen gehen kann.

    Gruß,
    UEZ ;)

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯

  • Kurz aber leider von der Darstellungsqualiltät nicht so gut wie die anderen Beispiele ;)
    Von dem her ist Post 14 immernoch gültig
    [ offen ] Bildgröße laufend an GUI anpassen

  • Hier die etwas längere Version, die das Bild entsprechend interpoliert.

    Spoiler anzeigen
    [autoit]


    #include <Constants.au3>
    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $STM_SETIMAGE = 0x0172
    Global $sPathKey = "HKLM64\SOFTWARE\AutoIt v3\AutoIt\"
    If @OSArch = "x64" Then $sPathKey = "HKLM\SOFTWARE\Wow6432Node\AutoIt v3\AutoIt\"
    Global $sImage = RegRead($sPathKey, "InstallDir") & "\Examples\GUI\logo4.gif"

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()
    Global $hBmp = _GDIPlus_BitmapCreateFromFile($sImage)
    Global $iW = _GDIPlus_ImageGetWidth($hBmp), $iH = _GDIPlus_ImageGetHeight($hBmp)

    [/autoit] [autoit][/autoit] [autoit]

    Global $hGUI = GUICreate("Test", 235, 112, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_THICKFRAME))
    Global $idPic = GUICtrlCreatePic("", 32, 16, $iW, $iH)
    GUICtrlSetResizing(-1, $GUI_DOCKVCENTER + $GUI_DOCKHCENTER)

    [/autoit] [autoit][/autoit] [autoit]

    Global $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp)
    Global $hB = GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap)
    If $hB Then _WinAPI_DeleteObject($hB)
    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_SIZE, "WM_SIZE")

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    _GDIPlus_BitmapDispose($hBmp)
    _GDIPlus_Shutdown()
    GUIDelete()
    Exit
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func WM_SIZE($hWnd, $Msg, $wParam, $lParam)
    #forceref $Msg, $wParam, $lParam
    Local $aSize = ControlGetPos($hWnd, "", $idPic)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $aSize[2], "int", $aSize[3], "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
    Local $hBitmap = $aResult[6]
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "handle", $hContext, "int", 7)
    _GDIPlus_GraphicsDrawImageRect($hContext, $hBmp, 0, 0, $aSize[2], $aSize[3])
    _GDIPlus_GraphicsDispose($hContext)
    Local $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
    Local $hB = GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap)
    If $hB Then _WinAPI_DeleteObject($hB)
    _WinAPI_DeleteObject($hHBitmap)
    _GDIPlus_BitmapDispose($hBitmap)
    Return "GUI_RUNDEFMSG"
    EndFunc

    [/autoit]

    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯

  • Hey UEZ, bei enormer Bildgröße (900x1000 oder sowas) flackert das Bild relativ heftig ...
    Das erste BSP mit dem Win7 Hintergrund lief bei mir am besten, aber irgendwie sah das Bild komisch aus :D

    Es gibt sehr viele Leute, die glauben. Aber aus Aberglauben.
    - Blaise Pascal