Hintergrundfarbe eines GUI IP Address Control Feldes ändern

  • Hat jemand noch eine Idee, wie man die Hintergrundfarbe eines GUI IP Address Control Feldes ändern kann?

    [autoit]


    #include <GuiConstantsEx.au3>
    #include <GuiIPAddress.au3>
    #include <WindowsConstants.au3>

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

    Opt("MustDeclareVars", 1)

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

    $Debug_IP = False ; Check ClassName being passed to IPAddress functions, set to True and use a handle to another control to see it work

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

    _Main()

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

    Func _Main()
    Local $hgui, $hIPAddress

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

    $hgui = GUICreate("IP Address Control Get (String) Example", 400, 300)
    $hIPAddress = _GUICtrlIpAddress_Create($hgui, 10, 10, 125, 25, BitOR($WS_TABSTOP,$WS_VISIBLE,$WS_CLIPSIBLINGS))

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

    GUISetState(@SW_SHOW)

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

    Local $tRECT = DllStructCreate($tagRect)
    DllStructSetData($tRECT, "Left", 0)
    DllStructSetData($tRECT, "Top", 0)
    DllStructSetData($tRECT, "Right", 125)
    DllStructSetData($tRECT, "Bottom", 25)

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

    Local $hBrush = _WinAPI_CreateSolidBrush(0x0000FF) ;BGR
    Local $hDC = _WinAPI_GetDC($hIPAddress)
    _WinAPI_FillRect($hDC, DllStructGetPtr($tRect), $hBrush)

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

    ;~ _GUICtrlIpAddress_Set ($hIPAddress, "24.168.2.128")
    _WinAPI_SetTextColor($hDC, 0x00)
    _WinAPI_SetBkColor($hDC, 0x0000FF)
    _WinAPI_SetBkMode($hDC, $TRANSPARENT)

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

    ; Wait for user to close GUI
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    $tRECT = ""
    _WinAPI_ReleaseDC(0, $hDC)
    _WinAPI_DeleteObject($hBrush)
    GUIDelete($hgui)
    Exit
    EndFunc ;==>_Main

    [/autoit]

    Sobald man was einträgt, überschreibt der Font den Hintergrund wieder...

    Oder vielleicht doch einen anderen Lösungsweg? ?(

    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯

  • Ich habe das mal so gemacht,

    [autoit]


    #include <GuiConstantsEx.au3>
    #include <GuiIPAddress.au3>
    #include <WindowsConstants.au3>

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

    Opt("MustDeclareVars", 1)

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

    $Debug_IP = False ; Check ClassName being passed to IPAddress functions, set to True and use a handle to another control to see it work

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

    Local $hgui, $hIPAddress

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

    $hgui = GUICreate("IP Address Control Get (String) Example", 400, 300)
    $hIPAddress = _GUICtrlIpAddress_Create($hgui, 10, 10, 125, 25, BitOR($WS_TABSTOP,$WS_VISIBLE,$WS_CLIPSIBLINGS))

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

    GUISetState(@SW_SHOW)

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

    Local $tRECT = DllStructCreate($tagRect)
    DllStructSetData($tRECT, "Left", 0)
    DllStructSetData($tRECT, "Top", 0)
    DllStructSetData($tRECT, "Right", 125)
    DllStructSetData($tRECT, "Bottom", 25)

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

    Local $hBrush = _WinAPI_CreateSolidBrush(0x0000FF) ;BGR
    Local $hDC = _WinAPI_GetDC($hIPAddress)
    _WinAPI_FillRect($hDC, DllStructGetPtr($tRect), $hBrush)

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

    ;~ Local $sFaceName = "Arial", $iFontSize = 12, $iFontWeight = 400, $fFontItalic = False
    ;~ Local $lfHeight = 14
    ;~ Local $tfont = DllStructCreate($tagLOGFONT)
    ;~ DllStructSetData($tfont, "Height", $lfHeight)
    ;~ DllStructSetData($tfont, "Weight", $iFontWeight)
    ;~ DllStructSetData($tfont, "Italic", $fFontItalic)
    ;~ DllStructSetData($tfont, "Underline", False) ; font underline
    ;~ DllStructSetData($tfont, "Strikeout", False) ; font strikethru
    ;~ DllStructSetData($tfont, "Quality", $__IPADDRESSCONSTANT_PROOF_QUALITY)
    ;~ DllStructSetData($tfont, "FaceName", $sFaceName)

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

    ;~ Local $font = _WinAPI_CreateFontIndirect($tfont)
    ;~ _WinAPI_SetFont($hIPAddress, $font)

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

    ;~ _GUICtrlIpAddress_Set ($hIPAddress, "24.168.2.128")
    ;~ _WinAPI_SetTextColor($hDC, 0x00)
    ;~ _WinAPI_SetBkColor($hDC, 0x0000FF)
    ;~ _WinAPI_SetBkMode($hDC, $TRANSPARENT)
    ;~ __EnumChild($hIPAddress)

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

    GUIRegisterMsg(0x0138, "_WM_CTLCOLORSTATIC")

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

    ; Wait for user to close GUI
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

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

    $tRECT = ""
    _WinAPI_ReleaseDC(0, $hDC)
    _WinAPI_DeleteObject($hBrush)
    GUIDelete($hgui)
    Exit

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

    Func _WM_CTLCOLORSTATIC($hWnd, $Msg, $wParam, $lParam)
    ConsoleWrite("Test" & @CRLF)
    Local $hDC = _WinAPI_GetDC($wParam)
    _WinAPI_SetTextColor($hDC, 0x00FF00)
    _WinAPI_SetBkColor($hDC, 0x0000FF)
    _WinAPI_SetBkMode($hDC, $TRANSPARENT)
    _WinAPI_ReleaseDC(0, $hDC)
    Return "GUI_RUNDEFMSG"
    EndFunc

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

    ;~ Func __EnumChild($hWnd, $lParam = 0)
    ;~ Local $hFunc = DllCallbackRegister("__EnumChildProc", "bool", "hwnd;lparam")
    ;~ DllCall("user32.dll", "bool", "EnumChildWindows", "hwnd", $hWnd, "ptr", DllCallbackGetPtr($hFunc), "lparam", $lParam)
    ;~ DllCallbackFree($hFunc)
    ;~ EndFunc ;==>__EnumChild

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

    ;~ Func __EnumChildProc($hWnd, $lParam)
    ;~ ConsoleWrite("child: " & $hWnd & @CRLF)
    ;~ WinSetTitle($hWnd, 0, "XXX")
    ;~ GUISetBkColor (0x0000FF, $hWnd)
    ;~ _WinAPI_SetTextColor($hDC, 0x00FF00)
    ;~ _WinAPI_SetBkColor($hDC, 0x0000FF)
    ;~ _WinAPI_SetBkMode($hDC, $TRANSPARENT)
    ;~ ;_WinAPI_SetBkColor...
    ;~ ;_SendMessage...
    ;~ Return 1
    ;~ EndFunc ;==>__EnumChildProc

    [/autoit]

    aber vielleicht ist das ja so falsch!

    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯