pammi Posted May 7, 2012 Posted May 7, 2012 Hi all, how to retrieve the column header type from Listview control. In my example, the first column is of checkbox header type and I need to fetch whether its enabled or not.
Moderators Melba23 Posted May 7, 2012 Moderators Posted May 7, 2012 pammi,Dog eaten your Help file? Try looking at _GUICtrlListView_GetItemChecked - that works for me. 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
KaFu Posted May 7, 2012 Posted May 7, 2012 Not sure, but I think the OP is searching more for something like this: Global Const $HDF_CHECKBOX = 0x0040 ; Windows Vista and Version 6.00. The item displays a checkbox. The flag is only valid when the HDS_CHECKBOXES style is first set on the header control. Global Const $HDF_CHECKED = 0x0080 ; Windows Vista and Version 6.00. The item displays a checked checkbox. The flag is only valid when HDF_CHECKBOX is also set. $h_Report_ListView_Header = _GUICtrlListView_GetHeader($hListview) For $i = 0 To _GUICtrlHeader_GetItemCount($hListview) - 1 $iFormat = _GUICtrlHeader_GetItemFormat($hListview, $i) If BitAND($iFormat, $HDF_CHECKBOX) Then ConsoleWrite("Column " & $i & " is of the typ HDF_CHECKBOX" & @CRLF) If BitAND($iFormat, $HDF_CHECKED) Then ConsoleWrite("Column " & $i & " is of the typ HDF_CHECKED" & @CRLF) Next OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
pammi Posted May 7, 2012 Author Posted May 7, 2012 @KaFu, does the $HDF_CHECKBOX and $HDF_CHECKED value change for windows XP.
KaFu Posted May 7, 2012 Posted May 7, 2012 Styles are only valid for Windows Vista+. Maybe post a screenshot of what you want. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
pammi Posted May 8, 2012 Author Posted May 8, 2012 Melba23,_GUICtrlListView_GetItemChecked doesn't work for column header.
pammi Posted May 8, 2012 Author Posted May 8, 2012 @KaFu, the column header is of sysheader32 type and the first column has a checkbox. I want to validate whether it exists or not. il attach the screenshot later.
pammi Posted May 8, 2012 Author Posted May 8, 2012 I mean the checkbox is in the first column header.
pammi Posted May 8, 2012 Author Posted May 8, 2012 @KaFu, attached is the snapshot of the app.I am trying to fetch the column header type of the first coulmn i.e checkbox.
BrewManNH Posted May 8, 2012 Posted May 8, 2012 What application are you using? Also, have you tried using the Au3Info tool on the header to see what it displays for the checkbox you're trying to get information from? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
pammi Posted May 8, 2012 Author Posted May 8, 2012 Its an windows application. Au3info tool doesn't fetch anything when pointed at the checkbox. It fetches the sysheader32 info of the column header as a whole. Is there any way to fetch the column header type using the index?
BrewManNH Posted May 8, 2012 Posted May 8, 2012 I'm pretty sure that I had figured out it was a Windows application, my question was which Windows application are you trying to interact with? What information do you get when you point it at the header, what is in the output pane of the info tool? All I have from you right now is it's a windows program with a listview, and nothing else. See why it's hard to figure out the answer to your questions yet? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
rover Posted May 9, 2012 Posted May 9, 2012 (edited) Its an windows application. Au3info tool doesn't fetch anything when pointed at the checkbox. It fetches the sysheader32 info of the column header as a whole. Is there any way to fetch the column header type using the index? There is no column header type to retrieve, a header checkbox in XP is a custom modification. The checkbox is either a child Button class control of SysHeader32, some non-MS class of listview/header/button or drawn. What is the listview class? You may need another tool like Winspector Spy, Ranorex or Window Detective to get the button info. If the AU3Info tool is not getting any info from the button, then it may be a custom class or drawn and not readable. I use a listview header checkbox in a script (written for XP) It looks like this in Winspector Spy or WinGetClassList($hListView) SysListview32 |_Sysheader32|_Button Something like this might return the button handle, then get the state. #include <GuiButton.au3> $hWin = WinGetHandle("[TITLE:YourApp]") If Not IsHWnd($hWin)Then Exit ConsoleWrite('!No App hWnd returned' & @crlf) $hListView = ControlGetHandle($hWin, "", "[CLASS:SysListView32]") If Not IsHWnd($hListView)Then Exit ConsoleWrite('!No ListView hWnd returned' & @crlf) $hBtn = ControlGetHandle($hListView, "", "[CLASS:Button]") If Not IsHWnd($hBtn)Then Exit ConsoleWrite('!No Button hWnd returned' & @crlf) $iRet = _GUICtrlButton_GetCheck($hBtn) If $iRet = $BST_CHECKED Then ConsoleWrite('+Button is checked' & @crlf) $iRet = ControlCommand($hBtn, "", $hBtn, "IsChecked", "") If $iRet = 1 Then ConsoleWrite('+Button is checked' & @crlf) Edited May 9, 2012 by rover I see fascists...
pammi Posted May 9, 2012 Author Posted May 9, 2012 @BrewManNH, Sorry I should have posted the info long back.its a C++ application. Below are the information about the column header from Au3info tool. >>>> Window <<<< Title: ABC Class: Afx:400000:8:10011:0:250455 Position: -4, -4 Size: 1032, 746 Style: 0x15CF8000 ExStyle: 0x00000110 Handle: 0x000A038A >>>> Control <<<< Class: SysHeader32 Instance: 2 ClassnameNN: SysHeader322 Name: Advanced (Class): [CLASS:SysHeader32; INSTANCE:2] ID: Text: Position: 258, 144 Size: 544, 17 ControlClick Coords: 15, 6 Style: 0x500000C2 ExStyle: 0x00000000 Handle: 0x000D0408 >>>> Mouse <<<< Position: 273, 196 Cursor ID: 0 Color: 0xFFFFFF
pammi Posted May 9, 2012 Author Posted May 9, 2012 @rover, Window Detective, Au3info tool is not identifying the checkbox in the header as a button. I used the below code and its not returning any handle to the button. Please have a look at the information about the header from Au3info above. #include <GuiButton.au3> $hWin = WinGetHandle("ABC") msgbox(0,"",$hWin) If Not IsHWnd($hWin)Then Exit ConsoleWrite('!No App hWnd returned' & @crlf) $hListView = ControlGetHandle($hWin, "", "[CLASS:SysHeader32; INSTANCE:2]") msgbox(0,"",$hListView) If Not IsHWnd($hListView)Then Exit ConsoleWrite('!No ListView hWnd returned' & @crlf) $hBtn = ControlGetHandle($hListView, "", "[CLASS:Button]") msgbox(0,"",$hBtn) If Not IsHWnd($hBtn)Then Exit ConsoleWrite('!No Button hWnd returned' & @crlf)
BrewManNH Posted May 9, 2012 Posted May 9, 2012 (edited) The strange thing is, that style setting for the header doesn't indicate that it has "$HDS_CHECKBOXES" (0x00000400) set on it. That number indicates it has WS_CHILD | WS_VISIBLE | HDS_HORZ | HDS_BUTTONS | HDS_DRAGDROP | HDS_FULLDRAG set. I got that information from here. So I'm not sure if you can get that information with AutoIt. Edited May 9, 2012 by BrewManNH If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
pammi Posted May 9, 2012 Author Posted May 9, 2012 thanks for the info BrewMan. The links explains everything.
rover Posted May 11, 2012 Posted May 11, 2012 (edited) Looks like no child MS Button class control in listview #2's header The listview and/or header may be ownerdrawn (unreadable with standard listview/header APIs) or using an imagelist (may be non-MS standard imagelist) There could be a header imagelist and hit testing used to change the image state. You may be able to get the items imagelist index for the checked/unchecked state. However, the placement of the checkbox in the image you posted suggests it is not an MS imagelist item as is not as indented as a header imagelist item is. Try this script, it will check if the listview is ownerdrawn. As a last resort, you could check pixel colour of the checkbox... Good Luck #include <GuiHeader.au3> #include <Constants.au3> #include <ListviewConstants.au3> $hWin = WinGetHandle("[TITLE:ABC]") If Not IsHWnd($hWin) Then Exit ConsoleWrite('!No App hWnd returned' & @CRLF) $hListView = ControlGetHandle($hWin, "", "[CLASS:SysListView32; INSTANCE:2]") If Not IsHWnd($hListView) Then Exit ConsoleWrite('!No ListView hWnd returned' & @CRLF) $Style = Hex(_WinAPI_GetWindowLong($hListView, $GWL_STYLE), 8) If (BitAND($Style, $LVS_OWNERDRAWFIXED) = $LVS_OWNERDRAWFIXED) Then MsgBox(0, 'SysListView32', 'SysListView32 has LVS_OWNERDRAWFIXED style') EndIf MsgBox(0, 'SysListView32', 'Instance 2 child controls:' & @CRLF & WinGetClassList($hListView)) $hHeader = ControlGetHandle($hWin, "", "[CLASS:SysHeader32; INSTANCE:2]") MsgBox(0, "SysHeader32", "handle: "& @CRLF & $hHeader& @CRLF & "column count: "& @CRLF & _GUICtrlHeader_GetItemCount($hHeader)) $hImgList = _GUICtrlHeader_GetImageList($hHeader) MsgBox(0, "GetImageList", _GUICtrlHeader_GetImageList($hHeader)) MsgBox(0, "GetItemCount", _GUICtrlHeader_GetItemCount($hImgList)) ;index of header column - first one should have the checkbox MsgBox(0, "GetItemImage", _GUICtrlHeader_GetItemImage($hImgList, 0)) ;state flags for header column - if using image list or ownerdrawn - see help file ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : _GUICtrlHeader_GetItemFlags($hHeader, 0) = ' & _GUICtrlHeader_GetItemFlags($hHeader, 0) & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : _GUICtrlHeader_GetItemDisplay($hHeader, 0) = ' & _GUICtrlHeader_GetItemDisplay($hHeader, 0) & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : _GUICtrlHeader_GetItemBitmap($hHeader, 0) = ' & _GUICtrlHeader_GetItemBitmap($hHeader, 0) & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console Edited May 11, 2012 by rover I see fascists...
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