Melque_Lima Posted October 26, 2016 Share Posted October 26, 2016 hi guys, i have a problem, i'm triying to set background color of a list view like that: $hListView = _GUICtrlListView_Create($Form2, "", 10, 90, $x-20, 200) $ID = _GUICtrlTreeView_GetItemParam($hListView) GUISetBkColor ($COLOR_RED,$ID) buts is not working, i try by these way bellow and its worked: $hListView = GUICtrlCreateListView("", 10, 90, $x-20, 200) GUICtrlSetBkColor(-1, $COLOR_RED) but at these way the function bellow doenst works: Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) If HWnd(DllStructGetData($tNMHDR, "hWndFrom")) = $hListView And DllStructGetData($tNMHDR, "Code") = $NM_DBLCLK Then $aLV_Click_Info = _GUICtrlListView_SubItemHitTest($hListView) If $aLV_Click_Info[0] <> -1 Then $fDblClk = True EndIf Return $GUI_RUNDEFMSG EndFunc can anyone help me? (sorry about my english) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 26, 2016 Moderators Share Posted October 26, 2016 Melque_Lima, Welcome to the AutoIt forums. But please stop PMing and double posting. Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online - like now! You need to understand the difference between the native AutoIt commands (GUICtrlCreate...) and the UDF commands (_GUICtrl..._Create) - the former return a ControlID which is used internally by AutoIt to address the control, where as the latter return a Windows handle which is used by Windows to identify almost everything in the system. If you look at the Help file for GUICtrlSetBkColor (not GUISetBkColor as you were using - that is only for GUIs, not controls) you will see that you need to use a ControlID to identify the control and so the function only works on ListViews created with the native commands. If you want to colour a UDF-created ListView, you need to use _GUICtrlListView_SetBkColor. Has that made any sense? Please tell me if not and we can take things a little slower. 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...
Melque_Lima Posted October 26, 2016 Author Share Posted October 26, 2016 sorry about it!!, and i try and it worked thakns, but look the result in attach, the backgound item, hot solve it? Link to comment Share on other sites More sharing options...
spudw2k Posted October 26, 2016 Share Posted October 26, 2016 Can you post a reproducer script (either snippet that produces issue or complete script)? I think you got the _GUICtrlListView_SetBkColor func figured out (...yes?), but not sure what you need help with now. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Melque_Lima Posted October 26, 2016 Author Share Posted October 26, 2016 spudw2k, the full code bellow expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiImageList.au3> #include <GuiButton.au3> #include <GuiListView.au3> #include <FontConstants.au3> #include <Misc.au3> #include <GuiTreeView.au3> Opt("GUIOnEventMode", 1) Opt("GUICloseOnESC", 0) HotKeySet("+!d",'Modo_ADM') Global $fDblClk = False Global $aLV_Click_Info, $hTmp_Edit = 0 $dll = DllOpen("user32.dll") #region configuração de form $x = 500 $y = 500 $w =(@DesktopWidth/2)-($x/2) $h =(@DesktopHeight/2)-($y/2) Global $Form2 = GUICreate("Tabela", $x, $y, $w, $h,BitOR($WS_POPUP, $DS_SETFOREGROUND)) GUISetBkColor(0x505050) GUICtrlSetDefColor(0xc1c1c1) #EndRegion #Region botoes de comando da janela $x_label = GUICtrlCreateLabel("X", 470, 10, 20, 20, BitOr($SS_NOTIFY, $SS_CENTER, $SS_CENTERIMAGE, $SS_SUNKEN)) GUISetOnEvent($GUI_EVENT_CLOSE, "close") GUICtrlSetOnEvent(-1, "close") GUICtrlSetBkColor(-1, 0x414141) $ctrlpos = ControlGetPos($Form2, "", $x_label) GUICtrlCreatePic(@ScriptDir & '\' & "gradient.bmp", $ctrlpos[0],$ctrlpos[1], $ctrlpos[2],$ctrlpos[3]) #EndRegion #Region Outros GUICtrlCreateLabel("-- Controle --", 10, 40, 480, 30, BitOr($SS_NOTIFY, $SS_CENTER, $SS_CENTERIMAGE, $SS_SUNKEN)) GUICtrlSetBkColor(-1, 0x991010) GUICtrlSetFont (-1,15,$FW_HEAVY) #EndRegion #Region Configurações de lista $hListView = _GUICtrlListView_Create($Form2, "", 10, 90, $x-20, 200) ;MsgBox(0,"",$hListView) _GUICtrlListView_SetBkColor($hListView,0x414141) ;$hListView = GUICtrlCreateListView("", 10, 90, $x-20, 200);,$LVS_NOCOLUMNHEADER ) ;MsgBox(0,"",_WinAPI_GetHandleInformation($hListView)) ;_GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR(0, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_INFOTIP)) ;GUICtrlSetBkColor(10000, 0x414141) ;$r = _GUICtrlTreeView_GetItemParam($hListView) ;GUISetBkColor ($COLOR_RED,$r) ;GUICtrlSetBkColor($r, 0x414141) _GUICtrlListView_AddColumn($hListView, "Nome",240) _GUICtrlListView_AddColumn($hListView, "Caixa 2",78) _GUICtrlListView_AddColumn($hListView, "Mensal",78) _GUICtrlListView_AddColumn($hListView, "Data",78) _GUICtrlListView_AddItem($hListView, "") ; Adciona uma nova linha _GUICtrlListView_AddSubItem($hListView,0,"TEST",0) _GUICtrlListView_AddSubItem($hListView,0,"5,235",1) _GUICtrlListView_AddSubItem($hListView,0,"1.0215.586",2) _GUICtrlListView_AddSubItem($hListView,0,"23/12/1991",3) #EndRegion #Region variaveis Global $fDblClk = False Global $hotkey = false #EndRegion ;$label3 = GUICtrlCreateLabel("Don't do that", 10,50, -1,-1, BitOr($SS_CENTER, $SS_CENTERIMAGE)) ;GUICtrlSetBkColor(-1, 0x991010) ;GUICtrlCreateLabel("Browse", 10, 10, 60, 25, BitOr($SS_NOTIFY, $SS_CENTER, $SS_CENTERIMAGE)) ;GUICtrlSetOnEvent(-1, "Hi") ;GUICtrlSetBkColor(-1, 0x414141) GUISetState(@SW_SHOW,$Form2) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 ; If a temporary edit exists If $hTmp_Edit <> 0 Then ; If ENTER pressed If _IsPressed("0D", $dll) Then ; Set label to edit content $sText = GUICtrlRead($hTmp_Edit) _GUICtrlListView_SetItemText($hListView, $aLV_Click_Info[0], $sText, $aLV_Click_Info[1]) ; Delete temporary edit GUICtrlDelete($hTmp_Edit) $hTmp_Edit = 0 EndIf ; If ESC pressed If _IsPressed("1B", $dll) Then ; Delete temporary edit GUICtrlDelete($hTmp_Edit) $hTmp_Edit = 0 EndIf EndIf ; If an item was double clicked If $fDblClk Then $fDblClk = False ; Delete any existing temporary edits GUICtrlDelete($hTmp_Edit) ;$hTmp_Edit = 0 ; Read current text of clicked label $sTmp_Text = _GUICtrlListView_GetItemText($hListView, $aLV_Click_Info[0], $aLV_Click_Info[1]) ; Get label position Switch $aLV_Click_Info[1] Case 0 ; On Item $aLV_Rect_Info = _GUICtrlListView_GetItemRect($hListView, $aLV_Click_Info[0], 2) Case Else ; On SubItem $aLV_Rect_Info = _GUICtrlListView_GetSubItemRect($hListView, $aLV_Click_Info[0], $aLV_Click_Info[1]) EndSwitch ; Create temporary edit $hTmp_Edit = GUICtrlCreateEdit($sTmp_Text, $aLV_Rect_Info[0] + 10, $aLV_Rect_Info[1] + 90, $aLV_Rect_Info[2] - $aLV_Rect_Info[0], $aLV_Rect_Info[3] - $aLV_Rect_Info[1], 0) GUICtrlSetState($hTmp_Edit, $GUI_FOCUS) EndIf WEnd func close() exit EndFunc Func Modo_ADM() if not $hotkey Then $hotkey = true Global $pass=InputBox("Security", "Digite a senha para modo ADM","" , "*M") if $pass == "senha" Then MsgBox(0,"","Acesso ADM autorizado!!") Else MsgBox(0,"","Senha incorreta") EndIf $hotkey = false EndIf EndFunc Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) If HWnd(DllStructGetData($tNMHDR, "hWndFrom")) = $hListView And DllStructGetData($tNMHDR, "Code") = $NM_DBLCLK Then $aLV_Click_Info = _GUICtrlListView_SubItemHitTest($hListView) If $aLV_Click_Info[0] <> -1 Then $fDblClk = True EndIf Return $GUI_RUNDEFMSG EndFunc lines between 48 and 74 the lines are with white background, how can i fix it? thanks for your support Link to comment Share on other sites More sharing options...
Melque_Lima Posted October 26, 2016 Author Share Posted October 26, 2016 1 minute ago, Melque_Lima said: spudw2k, the full code bellow expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiImageList.au3> #include <GuiButton.au3> #include <GuiListView.au3> #include <FontConstants.au3> #include <Misc.au3> #include <GuiTreeView.au3> Opt("GUIOnEventMode", 1) Opt("GUICloseOnESC", 0) HotKeySet("+!d",'Modo_ADM') Global $fDblClk = False Global $aLV_Click_Info, $hTmp_Edit = 0 $dll = DllOpen("user32.dll") #region configuração de form $x = 500 $y = 500 $w =(@DesktopWidth/2)-($x/2) $h =(@DesktopHeight/2)-($y/2) Global $Form2 = GUICreate("Tabela", $x, $y, $w, $h,BitOR($WS_POPUP, $DS_SETFOREGROUND)) GUISetBkColor(0x505050) GUICtrlSetDefColor(0xc1c1c1) #EndRegion #Region botoes de comando da janela $x_label = GUICtrlCreateLabel("X", 470, 10, 20, 20, BitOr($SS_NOTIFY, $SS_CENTER, $SS_CENTERIMAGE, $SS_SUNKEN)) GUISetOnEvent($GUI_EVENT_CLOSE, "close") GUICtrlSetOnEvent(-1, "close") GUICtrlSetBkColor(-1, 0x414141) $ctrlpos = ControlGetPos($Form2, "", $x_label) GUICtrlCreatePic(@ScriptDir & '\' & "gradient.bmp", $ctrlpos[0],$ctrlpos[1], $ctrlpos[2],$ctrlpos[3]) #EndRegion #Region Outros GUICtrlCreateLabel("-- Controle --", 10, 40, 480, 30, BitOr($SS_NOTIFY, $SS_CENTER, $SS_CENTERIMAGE, $SS_SUNKEN)) GUICtrlSetBkColor(-1, 0x991010) GUICtrlSetFont (-1,15,$FW_HEAVY) #EndRegion #Region Configurações de lista $hListView = _GUICtrlListView_Create($Form2, "", 10, 90, $x-20, 200) ;MsgBox(0,"",$hListView) _GUICtrlListView_SetBkColor($hListView,0x414141) ;$hListView = GUICtrlCreateListView("", 10, 90, $x-20, 200);,$LVS_NOCOLUMNHEADER ) ;MsgBox(0,"",_WinAPI_GetHandleInformation($hListView)) ;_GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR(0, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_INFOTIP)) ;GUICtrlSetBkColor(10000, 0x414141) ;$r = _GUICtrlTreeView_GetItemParam($hListView) ;GUISetBkColor ($COLOR_RED,$r) ;GUICtrlSetBkColor($r, 0x414141) _GUICtrlListView_AddColumn($hListView, "Nome",240) _GUICtrlListView_AddColumn($hListView, "Caixa 2",78) _GUICtrlListView_AddColumn($hListView, "Mensal",78) _GUICtrlListView_AddColumn($hListView, "Data",78) _GUICtrlListView_AddItem($hListView, "") ; Adciona uma nova linha _GUICtrlListView_AddSubItem($hListView,0,"TEST",0) _GUICtrlListView_AddSubItem($hListView,0,"5,235",1) _GUICtrlListView_AddSubItem($hListView,0,"1.0215.586",2) _GUICtrlListView_AddSubItem($hListView,0,"23/12/1991",3) #EndRegion #Region variaveis Global $fDblClk = False Global $hotkey = false #EndRegion ;$label3 = GUICtrlCreateLabel("Don't do that", 10,50, -1,-1, BitOr($SS_CENTER, $SS_CENTERIMAGE)) ;GUICtrlSetBkColor(-1, 0x991010) ;GUICtrlCreateLabel("Browse", 10, 10, 60, 25, BitOr($SS_NOTIFY, $SS_CENTER, $SS_CENTERIMAGE)) ;GUICtrlSetOnEvent(-1, "Hi") ;GUICtrlSetBkColor(-1, 0x414141) GUISetState(@SW_SHOW,$Form2) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 ; If a temporary edit exists If $hTmp_Edit <> 0 Then ; If ENTER pressed If _IsPressed("0D", $dll) Then ; Set label to edit content $sText = GUICtrlRead($hTmp_Edit) _GUICtrlListView_SetItemText($hListView, $aLV_Click_Info[0], $sText, $aLV_Click_Info[1]) ; Delete temporary edit GUICtrlDelete($hTmp_Edit) $hTmp_Edit = 0 EndIf ; If ESC pressed If _IsPressed("1B", $dll) Then ; Delete temporary edit GUICtrlDelete($hTmp_Edit) $hTmp_Edit = 0 EndIf EndIf ; If an item was double clicked If $fDblClk Then $fDblClk = False ; Delete any existing temporary edits GUICtrlDelete($hTmp_Edit) ;$hTmp_Edit = 0 ; Read current text of clicked label $sTmp_Text = _GUICtrlListView_GetItemText($hListView, $aLV_Click_Info[0], $aLV_Click_Info[1]) ; Get label position Switch $aLV_Click_Info[1] Case 0 ; On Item $aLV_Rect_Info = _GUICtrlListView_GetItemRect($hListView, $aLV_Click_Info[0], 2) Case Else ; On SubItem $aLV_Rect_Info = _GUICtrlListView_GetSubItemRect($hListView, $aLV_Click_Info[0], $aLV_Click_Info[1]) EndSwitch ; Create temporary edit $hTmp_Edit = GUICtrlCreateEdit($sTmp_Text, $aLV_Rect_Info[0] + 10, $aLV_Rect_Info[1] + 90, $aLV_Rect_Info[2] - $aLV_Rect_Info[0], $aLV_Rect_Info[3] - $aLV_Rect_Info[1], 0) GUICtrlSetState($hTmp_Edit, $GUI_FOCUS) EndIf WEnd func close() exit EndFunc Func Modo_ADM() if not $hotkey Then $hotkey = true Global $pass=InputBox("Security", "Digite a senha para modo ADM","" , "*M") if $pass == "senha" Then MsgBox(0,"","Acesso ADM autorizado!!") Else MsgBox(0,"","Senha incorreta") EndIf $hotkey = false EndIf EndFunc Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) If HWnd(DllStructGetData($tNMHDR, "hWndFrom")) = $hListView And DllStructGetData($tNMHDR, "Code") = $NM_DBLCLK Then $aLV_Click_Info = _GUICtrlListView_SubItemHitTest($hListView) If $aLV_Click_Info[0] <> -1 Then $fDblClk = True EndIf Return $GUI_RUNDEFMSG EndFunc lines between 48 and 74 the lines in listview are with white background color, how can i fix it? 1 minute ago, Melque_Lima said: thanks for your support Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 26, 2016 Moderators Share Posted October 26, 2016 Again, why are you double posting? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Melque_Lima Posted October 26, 2016 Author Share Posted October 26, 2016 i canot understand, what you mean when you say doule posting? i just posted this topic once!! Link to comment Share on other sites More sharing options...
Melque_Lima Posted October 26, 2016 Author Share Posted October 26, 2016 9 minutes ago, JLogan3o13 said: Again, why are you double posting? sorry i understand now, i just tried update my reply, i didnt know it double posted sorry i know now Link to comment Share on other sites More sharing options...
spudw2k Posted October 26, 2016 Share Posted October 26, 2016 You can use _GUICtrlListView_SetTextBkColor() to change the background color of the list view rows/items; just add it under the _SetBkColor func call. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Melque_Lima Posted October 26, 2016 Author Share Posted October 26, 2016 thanks a lot, its worked, hey, i tried to hide column headers and its doenst works fine, the others columns are gone, just column 0 are showing $hListView = _GUICtrlListView_Create($Form2, "", 10, 90, $x-20, 200,$LVS_NOCOLUMNHEADER) Link to comment Share on other sites More sharing options...
spudw2k Posted October 26, 2016 Share Posted October 26, 2016 $hListView = _GUICtrlListView_Create($Form2, "", 10, 90, $x-20, 200, BitOR($LVS_REPORT, $LVS_NOCOLUMNHEADER)) Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Melque_Lima Posted October 27, 2016 Author Share Posted October 27, 2016 10 hours ago, spudw2k said: $hListView = _GUICtrlListView_Create($Form2, "", 10, 90, $x-20, 200, BitOR($LVS_REPORT, $LVS_NOCOLUMNHEADER)) thanks a lot, it worked, 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