Transparentes Radio, Combobox

  • Abend,

    ich suche schon einiger Zeit eine UDF, um ein Radio oder eine Checkbox transparent zu machen, also einfach eine Funktion
    Hätte da jemand von euch vielleicht eine UDF oder könnte mir eben eine Funktion schreiben?

    Mit freundlichen Grüßen,

    Julien

  • Was willst du genau erreichen? Transparente Controls über einem Bild, oder wie genau. Warum auch Combobox? Für Checkbox habe ich mal was geschrieben und für Radiobuttons gibt es auch was.
    Wenn du das Windows Theme auschaltest (DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)) sollte $GUI_BKCOLOR_TRANSPARENT auch genügen.
    Aber eben je nachdem was du genau willst, gibt es immer eine Lösung.
    Schreib mal ein Beispielskript, damit man genau sieht was du möchtest.

  • Das ist aber nicht das gleiche. Checkbox geht da noch besser als ein Radiobutton.
    Hier mal mein Checkbox-Beispiel kurz erweitert:

    Spoiler anzeigen
    [autoit]

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

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

    Global Enum _
    $i_Start_Row = -1, _
    $i_hGUI_Row, $i_hPic_Row, $i_hCB_Row, _
    $i_Total_Rows
    Global $aTrnsChckBxs_DATA[1][$i_Total_Rows]

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

    Global $hGUI = GUICreate("Test transparent checkbox replacement", 400, 240)
    Global $nPic = GUICtrlCreatePic(@AutoItExe & "\..\Examples\GUI\msoobe.jpg", 0, 0, 400, 240, 0)

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

    GUICtrlCreateCheckbox("Standard checkbox", 10, 10, 200, 20)
    GUICtrlCreateCheckbox("Standard checkbox transparent", 10, 50, 200, 20)
    GUICtrlSetBkColor(-1, -2)
    GUICtrlCreateCheckbox("Standard checkbox without theme", 10, 90, 200, 20)
    GUICtrlSetBkColor(-1, -2)
    DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", "Explorer", "wstr", 0)

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

    GUICtrlCreateRadio("Standard checkbox without theme", 210, 90, 170, 20)
    GUICtrlSetBkColor(-1, -2)
    DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", "Explorer", "wstr", 0)

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

    GUICtrlCreateCheckbox("Standard checkbox workaround", 10, 130, 13, 13)
    GUICtrlCreateLabel("Standard checkbox workaround", 26, 130, 170, 13)
    GUICtrlSetBkColor(-1, -2)

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

    GUICtrlCreateRadio("Standard radio button workaround", 210, 130, 13, 13)
    GUICtrlCreateLabel("Standard radio button workaround", 226, 130, 200, 13)
    GUICtrlSetBkColor(-1, -2)

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

    Global $nCB1 = _GUICtrlTransCheckbox_Create($hGUI, $nPic, "TransparentCheckbox 1", 10, 170)
    Global $nCB2 = _GUICtrlTransCheckbox_Create($hGUI, $nPic, "TransparentCheckbox 2", 10, 210)

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

    GUISetState(@SW_SHOW, $hGUI)

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

    While 1
    $nGUIMsg = GUIGetMsg()

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

    Switch $nGUIMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $nCB1, $nCB2
    ConsoleWrite("CheckBox [" & GUICtrlRead($nGUIMsg, 1) & "] checked = " & (GUICtrlRead($nGUIMsg) = $GUI_CHECKED) & @LF)
    EndSwitch
    WEnd

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

    Func _GUICtrlTransCheckbox_Create($hGUI, $nBackPic, $sText, $iLeft, $iAbove, $iWidth = -1, $iHeight = -1, $iStyle = -1, $iExStyle = 0)
    Local $nCB = GUICtrlCreateCheckbox($sText, $iLeft, $iAbove, $iWidth, $iHeight, $iStyle, $iExStyle)
    Local $hCB = GUICtrlGetHandle($nCB)
    Local $hPic = GUICtrlGetHandle($nBackPic)

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

    If $aTrnsChckBxs_DATA[0][0] = 0 Then
    GUIRegisterMsg($WM_NOTIFY, '_TrnsChckBx_WM_NOTIFY')
    EndIf

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

    $aTrnsChckBxs_DATA[0][0] += 1
    ReDim $aTrnsChckBxs_DATA[$aTrnsChckBxs_DATA[0][0] + 1][$i_Total_Rows]

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

    $aTrnsChckBxs_DATA[$aTrnsChckBxs_DATA[0][0]][$i_hGUI_Row] = $hGUI
    $aTrnsChckBxs_DATA[$aTrnsChckBxs_DATA[0][0]][$i_hPic_Row] = $hPic
    $aTrnsChckBxs_DATA[$aTrnsChckBxs_DATA[0][0]][$i_hCB_Row] = $hCB

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

    Return $nCB
    EndFunc ;==>_GUICtrlTransCheckbox_Create

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

    Func _GUICtrlTransCheckbox_Delete($nChckBx)
    Local $hCB = GUICtrlGetHandle($nChckBx)
    Local $aTmp[$aTrnsChckBxs_DATA[0][0]][$i_Total_Rows]

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

    GUICtrlDelete($nChckBx)

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

    For $i = 1 To $aTrnsChckBxs_DATA[0][0]
    If $aTrnsChckBxs_DATA[$i][$i_hCB_Row] <> $hCB Then
    $aTmp[0][0] += 1

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

    $aTmp[$aTmp[0][0]][$i_hGUI_Row] = $aTrnsChckBxs_DATA[$i][$i_hGUI_Row]
    $aTmp[$aTmp[0][0]][$i_hPic_Row] = $aTrnsChckBxs_DATA[$i][$i_hPic_Row]
    $aTmp[$aTmp[0][0]][$i_hCB_Row] = $aTrnsChckBxs_DATA[$i][$i_hCB_Row]
    EndIf
    Next

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

    ReDim $aTmp[$aTmp[0][0] + 1][$i_Total_Rows]
    $aTrnsChckBxs_DATA = $aTmp

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

    Return $aTmp[0][0]
    EndFunc ;==>_GUICtrlTransCheckbox_Delete

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

    Func _TrnsChckBx_WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    Local $hWndFrom, $iIDFrom, $tNMHDR
    Local Const $tagNMCUSTOMDRAW = 'hwnd hWndFrom;uint_ptr IDFrom;int_ptr Code;dword DrawStage;hwnd hDC;' & $tagRECT & ';dword_ptr ItemSpec;uint ItemState;lparam ItemlParam'

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

    Local Const $STM_GETIMAGE = 0x0173

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

    Local $tNMCD = DllStructCreate($tagNMCUSTOMDRAW, $lParam)
    Local $hWndFrom = DllStructGetData($tNMCD, 'hWndFrom')
    Local $iCode = BitOR(DllStructGetData($tNMCD, 'Code'), 0)
    Local $DrawStage = DllStructGetData($tNMCD, 'DrawStage')
    Local $ItemSpec = DllStructGetData($tNMCD, 'ItemSpec')
    Local $hDC = DllStructGetData($tNMCD, 'hDC')
    Local $hPic, $aPos, $hMemDC, $hBitmap, $hPrev
    Local $iAbove, $iBeneath, $iBoxSize = 13
    For $i = 1 To $aTrnsChckBxs_DATA[0][0]
    If $hWndFrom = $aTrnsChckBxs_DATA[$i][$i_hCB_Row] Then
    Switch $iCode
    Case $NM_CUSTOMDRAW
    Switch $DrawStage
    Case $CDDS_PREPAINT
    $hPic = $aTrnsChckBxs_DATA[$i][$i_hPic_Row]
    $aPos = ControlGetPos($hWnd, '', $hWndFrom)

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

    If @error Then
    ExitLoop
    EndIf

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

    If $aPos[3] < $iBoxSize Then $iBoxSize = $aPos[3]
    $iAbove = Floor(($aPos[3] - $iBoxSize) / 2)
    $iBeneath = $iAbove + $iBoxSize

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

    $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
    $hBitmap = _SendMessage($hPic, $STM_GETIMAGE, $IMAGE_BITMAP, 0)
    $hPrev = _WinAPI_SelectObject($hMemDC, $hBitmap)
    _WinAPI_BitBlt($hDC, 0, 0, $iBoxSize, $iAbove, $hMemDC, $aPos[0], $aPos[1], $SRCCOPY) ;field above checkbox
    _WinAPI_BitBlt($hDC, 0, $iBeneath, $iBoxSize, $iBeneath - $iAbove, $hMemDC, $aPos[0], $aPos[1] + $iBeneath, $SRCCOPY) ;field beneath checkbox
    _WinAPI_BitBlt($hDC, $iBoxSize, 0, $aPos[2] - $iBoxSize, $aPos[3], $hMemDC, $aPos[0] + $iBoxSize, $aPos[1], $SRCCOPY) ;checkbox text field
    _WinAPI_SelectObject($hMemDC, $hPrev)
    _WinAPI_DeleteDC($hMemDC)
    Return $CDRF_DODEFAULT
    EndSwitch
    EndSwitch

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

    ExitLoop
    EndIf
    Next

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

    Return $GUI_RUNDEFMSG
    EndFunc ;==>_TrnsChckBx_WM_NOTIFY

    [/autoit]
  • Ich habe nun DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) am Anfang des Skriptes benutzt und nun gehen die Radio Buttons auch transparent, danke. ;)
    Nun muss ich nur noch den Slider Hintergrund transparent bekommen, was muss ich denn dafür machen?

  • Der weiße Hintergrund soll komplett weg, weil ich ein Bild dahinter haben möchte und es total blöd aussieht, wenn man dann den weißen Hintergrund beim Slider hat.