Jump to content

Guictrlsetbkcolor not working with EDIT UDF


CodyBarrett
 Share

Recommended Posts

i can't seem to get any function to work with

$hwnd = _GUICtrlEdit_Create ()

GUIctrlsetBkColor (_WinApi_GetDLGCtrlID($hwnd),0xFF0000) ; Doesn't work.
;And
_WinAPI_SetBkColor($hwnd,0xFF0000) ;Doesn't Work
;And
_WinAPI_SetBkColor(_WinAPI_GetDC($hwnd),0xFF0000);Doesn't Work either...

what could i use to color the background of the UDF's created EDIT?

Link to comment
Share on other sites

There must be a better way, but this is what I got after reading up on WM_CTLCOLOREDIT:

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <GUIEdit.au3>

$hGUI = GUICreate("Test", 400, 300)
$hEdit = _GUICtrlEdit_Create($hGUI, "Test Edit control.", 20, 20, 360, 150)
GUIRegisterMsg($WM_CTLCOLOREDIT, 'WM_CTLCOLOREDIT')
GUISetState(@SW_SHOW)

While 1
    $gm = GUIGetMsg()
    Switch $gm
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

Func WM_CTLCOLOREDIT($hWnd, $iMsg, $iWParam, $iLParam)
    If $iLParam = $hEdit Then
        $hBrush = _WinAPI_CreateSolidBrush(0xFF0000)
        Return $hBrush
    Else
        Return $GUI_RUNDEFMSG
    EndIf
EndFunc   ;==>WM_CTLCOLOREDIT

:graduated:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

uhm. it colored the NON text area, but once text was entered it became white, sigh...

Link to comment
Share on other sites

Yeah, I saw that too. Maybe the standard API for an edit control is just not meant to support this.

Now if you switch to a RichEdit control, then you can do this directly with an EM_SETBKGNDCOLOR message, which already in the UDF as _GUICtrlRichEdit_SetBkColor().

(No, that won't work on a regular Edit.)

:graduated:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

why does

GUICTRLCREATEEDIT () work with color

and

_GUICTRLEDIT_CREATE () doesn't

?? :\ just curious.

Link to comment
Share on other sites

Some of the native AutoIt controls have some funky "owner drawn" stuff going on in the background. If you poke around enough in the bug tracker you see some broken behaviors that can't be fixed until the Devs rewrite some deep stuff in the GUI code. (Which means it won't be changed for a while.) I know of some particular problems with setting colors on a button in combination with certain style options, for example.

I should point out that I DON'T know that this particular problem is the same. Maybe somebody smarter than me will show us both how to easily do what you originally wanted.

:graduated:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...