ClipGet in GUICtrlCreatePic und das noch in Original Größe?!

  • Hi, ich glaube der Titel sagt schon alles...wie stelle ich das an mit ClipGet das Pic in GUICtrlCreatePic zu packen und das noch in der Originalen Größe...
    Hier mal so wie ich mir das gedacht habe^^...

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

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

    $Gui = GUICreate("GlipGet", 754, 417, 193, 125)
    $Pic1 = GUICtrlCreatePic("", 8, 8, 600, 400, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $ClipGet = GUICtrlCreateButton("ClipGet", 616, 8, 129, 25, 0)
    GUISetState(@SW_SHOW)

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

    While 1

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

    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    Exit
    Case $ClipGet
    start()
    EndSwitch

    WEnd

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

    func start()
    GUICtrlSetImage($Pic1,ClipGet())
    EndFunc

    [/autoit]
  • Also ich würd das Bild erstmal im temp-Verzeichnis speichern und dann die Größe ermitteln und dann das Bild in die GUI bringen

  • Mhmm, hatte ich mir hinterher auch so gedacht.. :) ich änder das mal eben... Trotzdem danke für den Tipp

  • Du brauchst die ClipBoard-UDF von AutoIt :)

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #include <WinAPI.au3>
    #include <ClipBoard.au3>

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

    #Region - GUI Create
    $GUI = GUICreate('ClipImageGet')
    $button = GUICtrlCreateButton("Get IMG", 0, 0, 100, 20)
    $img = GUICtrlCreatePic("", 0, 25)
    GUISetState()
    #EndRegion - GUI Create

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

    #Region - GUI SelectLoop
    While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
    Exit
    Case $msg = $button
    $Image = _GetImageFromClip($GUI)
    If Not @error Then _SetBitmapToCtrl($img, $Image)
    EndSelect
    WEnd
    #EndRegion - GUI SelectLoop

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

    ;===============================================================================
    ;
    ; Function Name: _GetImageFromClip()
    ; Description:: Copies the Bitmap in the Clipboard for usage in the script
    ; Parameter(s): $hwnd [optional] -> a Window-Handle, used to lock the ClipBoard for the Script
    ; Requirement(s): ClipBoard.au3, WinAPI.au3
    ; Return Value(s): Success: Handle of the new HBITMAP
    ; Error: 0 and @eeror set to
    ; 1 -> No Bitmap in Clipboard
    ; 2 -> Could not get the Bitmap
    ; 3 -> Could not make a copy of it
    ; 4 -> Could not open ClipBoard
    ; Author(s): Prog@ndy
    ;
    ;===============================================================================
    ;
    Func _GetImageFromClip($hWnd = Default)
    Local $Return = 0, $error = 0, $temp
    If Not IsHWnd($hWnd) Then $hWnd = GUICreate("ClipGet Image HWND~~~~~~~###!$§$%$" & @AutoItPID)
    $temp = _ClipBoard_Open($hWnd)
    If $temp Then
    If _ClipBoard_IsFormatAvailable($CF_BITMAP) Then
    Local $HClipIMG = _ClipBoard_GetDataEx($CF_BITMAP)
    If @error Then
    $error = 2
    Else
    $Return = _WinAPI_CopyImage($HClipIMG)
    If @error Then
    $Return = 0
    $error = 3
    EndIf
    EndIf
    Else
    $error = 1
    EndIf
    _ClipBoard_Close()
    Else
    $error = 4
    EndIf
    If WinGetTitle($hWnd) = "ClipGet Image HWND~~~~~~~###!$§$%$" & @AutoItPID Then GUIDelete($hWnd)
    Return SetError($error, 0, $Return)
    EndFunc ;==>_GetImageFromClip

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

    ; Function: _SetBitmapToCtrl Out of Zedna's resources.au3
    ; internal helper function
    Func _SetBitmapToCtrl($CtrlId, $hBitmap)
    Local Const $STM_SETIMAGE = 0x0172
    Local Const $IMAGE_BITMAP = 0
    Local Const $SS_BITMAP = 0xE
    Local Const $GWL_STYLE = -16

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

    Local $hWnd = GUICtrlGetHandle($CtrlId)
    If $hWnd = 0 Then Return SetError(1, 0, 0)

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

    ; set SS_BITMAP style to control
    Local $oldStyle = DllCall("user32.dll", "long", "GetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE)
    If @error Then Return SetError(2, 0, 0)
    DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE, "long", BitOR($oldStyle[0], $SS_BITMAP))
    If @error Then Return SetError(3, 0, 0)

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

    Local $oldBmp = DllCall("user32.dll", "hwnd", "SendMessage", "hwnd", $hWnd, "int", $STM_SETIMAGE, "int", $IMAGE_BITMAP, "int", $hBitmap)
    If @error Then Return SetError(4, 0, 0)
    If $oldBmp[0] <> 0 Then _WinAPI_DeleteObject($oldBmp[0])
    Return 1
    EndFunc ;==>_SetBitmapToCtrl
    ;===============================================================================
    ;
    ; Function Name: _WinAPI_CopyImage
    ; Description:: Copies an image, also makes GDIPlus-HBITMAP to GDI32-BITMAP
    ; Parameter(s): $hImg -> HBITMAP Object, GDI or GDIPlus
    ; Requirement(s): WinAPI.au3
    ; Return Value(s): Succes: Handle to new Bitmap, Error: 0
    ; Author(s): Prog@ndy
    ;
    ;===============================================================================
    ;
    Func _WinAPI_CopyImage($hImg, $uType = 0, $x = 0, $y = 0, $flags = 0)
    Local $aResult

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

    $aResult = DllCall("User32.dll", "hwnd", "CopyImage", "hwnd", $hImg, "UINT", $uType, "int", $x, "int", $y, "UINT", $flags)
    _WinAPI_Check("_WinAPI_CopyImage", ($aResult[0] = 0), 0, True)
    Return SetError($aResult[0] = 0, 0, $aResult[0])
    EndFunc ;==>_WinAPI_CopyImage

    [/autoit]


    Nur ein Problemchaen noch :) Entweder Scrollbars einfügen oder das Fenster auf Control-Größe bringen, wenn eine Bitmap eingefügt wird.

  • Hmm..funzt nicht so wirklich, wie ich das wollte.. siehe hier das was ich nachbauen möchte...

  • Ammm...nicht wirklich...oder sieht das prog wie ein Bot aus... ?(
    Das manch Leute immer voreilig ihr Urteil bilden..naja...

  • Ne, also für diese Zwecke sollte es eig. nicht sein... sagen wir es mal so... ich bin noch in der 'Lern-Phase' wo ich mir simple programme raussuche, und sie nachbauen möchte. ;)