Radio Buttons auf Hintergrundbild

  • Hallo,
    ich habe zwar nach einer Lösung gesucht, aber keine brauchbare gefunden.

    Ich hätte gerne einen Radiobutton auf einem Hintergrundbild. Leider funktioniert der CODe

    [autoit]

    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

    [/autoit]

    zwar bei allen anderen GUI elementen, aber nicht bei Radio und Checkboxen.

    Ist das richtig?
    Gibt es eine einfache Möglichkeit?
    Bei Checkboxen habe ich die Grösse so klein gemacht, dass nur die Checkbox zu sehen ist, bei Raduiobuttons geht das ja auch nicht weil die rund sind??

    Danke

    Einmal editiert, zuletzt von lumb (29. März 2011 um 11:48)

  • Bitte mal den ganzen Code posten.

    Lieben Gruß,
    Alina

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Geheime Information: ;)
    k3mrwmIBHejryPvylQSFieDF5f3VOnk6iLAVBGVhKQegrFuWr3iraNIblLweSW4WgqI0SrRbS7U5jI3sn50R4a15Cthu1bEr

  • Dann bin ich ja mal gespannt ob Du mit dem Code eine Lösung weisst. Danke schoneinmal für Deine Mühe:

    [autoit]

    #AutoIt3Wrapper_res_requestedExecutionLevel=requireAdministrator
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <GUIConstants.au3>
    #include <File.au3>
    #include <Array.au3>
    #include <Clipboard.au3>
    #RequireAdmin

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

    GUICreate("", 816, 615, 192, 124)
    GUISetFont(10, 400, 0, "Arial")
    GUICtrlCreatePic(@TempDir & "\KS3.jpg", 0, 0, 816,615)
    GUICtrlSetSTate(-1,$GUI_DISABLE)

    $GUIRadioButton = GUICtrlCreateRadio("Button1", 616, 140, 180, 20)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUISetState(@SW_SHOW)
    While 1
    Wend

    [/autoit]
  • Hab mal schnell was gebastelt.

    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]

    $hGUI = GUICreate("Test transparent checkbox replacement", 400, 200)

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

    $nRadio1 = _GUICtrlTransRadio_Create($hGUI, "TransparentRadio1", 200, 33)
    $nRadio2 = _GUICtrlTransRadio_Create($hGUI, "TransparentRadio2", 200, 53)

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

    $nPic = GUICtrlCreatePic(@AutoItExe & "\..\Examples\GUI\msoobe.jpg", 0, 0, 400, 200, 0)

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

    $nCB1 = _GUICtrlTransCheckbox_Create($hGUI, $nPic, "TransparentCheckbox 1", 10, 30)
    $nCB2 = _GUICtrlTransCheckbox_Create($hGUI, $nPic, "TransparentCheckbox 2", 10, 50)

    [/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)
    Case $nRadio1
    GUICtrlSetState($nRadio2, 4)
    Case $nRadio2
    GUICtrlSetState($nRadio1, 4)
    EndSwitch
    WEnd

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

    Func _GUICtrlTransRadio_Create($hGUI, $sText, $iLeft, $iAbove, $iWidth = -1, $iHeight = -1)
    Local $hRadioChild = GUICreate("", 13, 13, $iLeft, $iAbove, 0x40000000, 0x20, $hGUI)
    Local $nRadio = GUICtrlCreateRadio("", 0, 0, 13, 13)
    Local $rgn = _WinAPI_CreateRoundRectRgn(1, 1, 13, 13, 10, 10)
    _WinAPI_SetWindowRgn($hRadioChild, $rgn)
    _WinAPI_DeleteObject($rgn)

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

    GUISetState()
    GUISwitch($hGUI)
    GUICtrlCreateLabel($sText, $iLeft + 18, $iAbove, $iWidth, $iHeight, -1, 0x28)
    GUICtrlSetBkColor(-1, -2)
    Return $nRadio
    EndFunc ;==>_GUICtrlTransRadio_Create

    [/autoit] [autoit][/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'
    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]
  • Hi lumb,

    hier habe mal einige Möglichkeiten als Beispiel:

    [autoit]


    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>

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

    $Form1_1 = GUICreate("Big Radiobox", 210, 180, 300, 233)
    ;i normale Radiobox
    $Radiobox0 = GUICtrlCreateRadio("Radiobox basic", 10, 10, 180, 35)
    ;i Radiobox color
    DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
    $Radiobox1 = GUICtrlCreateRadio("Radiobox color", 10, 50, 180, 35)
    GUICtrlSetColor(-1, 0xFF0000) ;i rot
    DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 7)
    ;i große Radiobox Schriftart und Größe anders
    $Radiobox2 = GUICtrlCreateRadio("Radiobox", 10, 90, 180, 35, $BS_PUSHLIKE)
    GUICtrlSetFont(-1, 12, 400, 0, "Wingdings")
    ;i große Radiobox mit Icon
    $Radiobox3 = GUICtrlCreateRadio("&s", 10, 130, 180, 35, BitOR($BS_ICON, $BS_PUSHLIKE))
    GUICtrlSetImage(-1, "shell32.dll", 7)

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

    GUISetState(@SW_SHOW)

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

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

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

    ;i ENDE

    [/autoit]
  • Ich habe selbst etwas gefunden. Und zwar binde ich da Hintergrundbild mit folgenden Optionen ein:

    [autoit]

    GUICtrlCreatePic(@TempDir & "\KS4.jpg", 0, 25, 816,615)
    GUICtrlSetSTate(-1,$GUI_DISABLE)
    GUICtrlSetSTate(-1,$WS_CLIPSIBLINGS)

    [/autoit]

    Dann ist alles schön. Checkboxen und Radiobuttons sind durchsichtig...
    Spricht da was dagegen?