Sign in to follow this  
Followers 0
pammi

Get column header type from Listview control

18 posts in this topic

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.

Share this post


Link to post
Share on other sites



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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

@KaFu,

does the $HDF_CHECKBOX and $HDF_CHECKED value change for windows XP.

Share this post


Link to post
Share on other sites

Melba23,

_GUICtrlListView_GetItemChecked doesn't work for column header.

Share this post


Link to post
Share on other sites

@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.

Share this post


Link to post
Share on other sites

I mean the checkbox is in the first column header.

Share this post


Link to post
Share on other sites

@KaFu,

attached is the snapshot of the app.I am trying to fetch the column header type of the first coulmn i.e checkbox.

post-71953-0-70220300-1336489043_thumb.j

Share this post


Link to post
Share on other sites

#10 ·  Posted

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 Gude
How 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

Share this post


Link to post
Share on other sites

#11 ·  Posted

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?

Share this post


Link to post
Share on other sites

#12 ·  Posted

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 Gude
How 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

Share this post


Link to post
Share on other sites

#13 ·  Posted (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 by rover

I see fascists...

Share this post


Link to post
Share on other sites

#14 ·  Posted

@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

Share this post


Link to post
Share on other sites

#15 ·  Posted

@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)

Share this post


Link to post
Share on other sites

#16 ·  Posted (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 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 Gude
How 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

Share this post


Link to post
Share on other sites

#17 ·  Posted

thanks for the info BrewMan. The links explains everything.

Share this post


Link to post
Share on other sites

#18 ·  Posted (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 by rover

I see fascists...

Share this post


Link to post
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
Sign in to follow this  
Followers 0