Bild in einem Tab zeigen über GDI+ ???

  • So, nun hab ich schon wieder ein Problem:
    Ein mit GDI+ geladenes Bild auf einem Tab-Element eines Guis zeigen. Was gut wäre, es an ein:

    [autoit]

    GUICtrlCreatePic ( filename, left, top [, width [, height [, style [,
    exStyle]]]] )

    [/autoit]


    zu schicken.
    Jedoch fand ich keine Lösung für dieses Problem. Vielleicht kenn jemand ein passenden Befehl?

    4 Mal editiert, zuletzt von Faweyr (7. Dezember 2009 um 14:41)

  • So, nun war ich zu voreilig.
    Ich benutze diese Funktion:

    [autoit]

    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]

    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 DllCall("GDI32.dll", "int", "DeleteObject", "int", $oldBmp[0])
    Return 1
    EndFunc ;==>_SetBitmapToCtrl

    [/autoit]


    Nun mein Problem:
    Es kopiert das Bild über das alte, wenn ich diese Funktion zum 2 mal anwende. Nach minimieren und maximieren des GUi´s, ist wieder alles in ordnung.
    Meine Frage: kann man dieses Problem beheben? :)

  • Soll es n icht dein Bild über das alte kopieren???

    Eine lösung wäre es nur 1mal anzuwenden :rofl:

    Mfg

    Computers are like Airconditioning. They don´t work with open Windows.

  • Ah verstehe.

    Ich hab leider nicht besonders viel Ahnung von GDI+, kannst ja mal UEZ fragen, der weis sicher wie das geht.

    Mfg

    Computers are like Airconditioning. They don´t work with open Windows.

  • Nun hab ich auch dafür eine unkonventionelle Lösung gefunden. Ich schiebe vor das neu anzuzeigende Bild einfach ein Bild mit der gleichen Größe, das die Hintergrundfarbe des Guis hat.
    Code:

    [autoit]

    _SetBitmapToCtrl($bpic[$i],_GUICtrlListView_CreateSolidBitMap($listview, 0xfaf9f8, 40, 40) ) ;Zeigt das Bild mit der Hintergrundfarbe "0xfaf9f8"
    _SetBitmapToCtrl($bpic[$i], _GDIPlus_BitmapCreateHBITMAPFromBitmap($food[2][$i])) ;Nun wird das eigentlich Bild angezeigt.

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

    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]

    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 DllCall("GDI32.dll", "int", "DeleteObject", "int", $oldBmp[0])
    Return 1
    EndFunc ;==>_SetBitmapToCtrl

    [/autoit]