d0n Posted March 7, 2010 Share Posted March 7, 2010 which function should i look at to get the text color inside a listbox? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 7, 2010 Moderators Share Posted March 7, 2010 d0n,If it is your own editbox, you should know already! But I wrote this a while ago to get the colours from a control - it is a bit "rough and ready", but it seems to do the trick. Just remember to allow for the editbox border:expandcollapse popup#include <GUIConstantsEx.au3> #include <WinAPI.au3> Global $aSetColors[2] = [0xFF0000, 0x00FF00] $hGUI = GUICreate("Test", 500, 500) $hEdit = GUICtrlCreateEdit("Testing" & @CRLF & "Testing!" , 10, 10, 200, 202) GUICtrlSetColor(-1, $aSetColors[0]) GUICtrlSetBkColor(-1, $aSetColors[1]) $hButton = GUICtrlCreateButton("Get Colours", 10, 350, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton $aGetColors = _GetColors($hEdit) If @error Then ConsoleWrite("No text available to read" & _ @CRLF & "Background: Set: " & Hex($aSetColors[1], 6) & " - Get: " & Hex($aGetColors[1], 6) & @CRLF) Else ConsoleWrite("Foreground: Set: " & Hex($aSetColors[0], 6) & " - Get: " & Hex($aGetColors[0], 6) & _ @CRLF & "Background: Set: " & Hex($aSetColors[1], 6) & " - Get: " & Hex($aGetColors[1], 6) & @CRLF) EndIf EndSwitch WEnd Func _GetColors($hControl) Local $aColors[2], $tpoint = DllStructCreate("int X;int Y") ; Get position of control Local $aPos = ControlGetPos($hGUI, "", $hControl) ; Convert to screen coords DllStructSetData($tpoint, "X", $aPos[0]) DllStructSetData($tpoint, "Y", $aPos[1]) _WinAPI_ClientToScreen($hGUI, $tPoint) $aPos[0] = DllStructGetData($tpoint, "X") + 4 ; Need to get over the border pixels $aPos[1] = DllStructGetData($tpoint, "Y") + 4 ; read colour at top left - assume it is background $aColors[1] = PixelGetColor($aPos[0], $aPos[1]) ; Sweep through first character of control to find another colour For $iX = $aPos[0] To $aPos[0] + 10 For $iY = $aPos[1] To $aPos[1] + 10 If PixelGetColor($iX, $iY) <> $aColors[1] Then ; Assume that it is text colour $aColors[0] = PixelGetColor($iX, $iY) Return $aColors EndIf Next Next ; Text colour not found, so return array, but set error as a flag $aColors[0] = 0 Return SetError(-1, 0, $aColors) EndFuncI hope it helps. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
d0n Posted March 7, 2010 Author Share Posted March 7, 2010 well its not mine and is there a way to read it without using pixelgetcolor? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 7, 2010 Moderators Share Posted March 7, 2010 d0n,Perhaps this topic might help. M23P.S. The Search button is at the top on the right. Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
d0n Posted March 7, 2010 Author Share Posted March 7, 2010 i've tried that one, I can't get it to work with a listbox Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 7, 2010 Moderators Share Posted March 7, 2010 d0n, I never got it to work with anything, which is why I wrote the function I posted above. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now