Jump to content

Unchecking a ListViewItem fails: code or documentation or me?


c.haslam
 Share

Recommended Posts

Here's a test script:

#include
#include
#include

GUICreate("My Alarm", 623, 705 - 1, -1)
Local $lvMsgs = GUICtrlCreateListView("Date|Time|Message", 24, 176, 577, 513, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_FULLROWSELECT))
Local $n = BitOR($LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg(-1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $n, $n)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 226)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 53)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 293 - 15)
GUISetState(@SW_SHOW)

Local $lviVec[2]
For $i = 0 To 1
$lviVec[$i] = GUICtrlCreateListViewItem('Row '&$i&' Col 1| Row '&$i&' Col 2 | Row '&$i&' Col 3', $lvMsgs)
Next

MsgBox(4096,"","Check the first row, then click OK")

GUICtrlSetState($lviVec[0],$GUI_UNCHECKED)

MsgBox(4096,"","The checkmark is still there!")

I have read the Help for GUICtrlSetState() several times. It seems to say that the check-mark should be cleared.

Suggestions?

Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Link to comment
Share on other sites

What is the need of setting the Extended styles using message

As said in the msdn the message would affect every parameter present in the wParam

hence the code wasnt working

try this

#include <WindowsConstants.au3>
#include <ListViewConstants.au3>
#include <GuiConstants.au3>

GUICreate("My Alarm", 623, 705 - 1, -1)
Local $lvMsgs = GUICtrlCreateListView("Date|Time|Message", 24, 176, 577, 513, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES))
GUISetState(@SW_SHOW)


$nListItm = GUICtrlCreateListViewItem('Row ' & 0 & ' Col 1| Row ' & 0 & ' Col 2 | Row ' & 0 & ' Col 3', $lvMsgs)
GUICtrlSetState( $nListItm, $GUI_CHECKED)
Sleep(3000)
GUICtrlSetState( $nListItm, $GUI_UNCHECKED)

While GUIGetMsg() <> -3
Sleep( 10 )
WEnd
Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

Thank you for the help. I would be interested in knowing where MSDN says that "the message would affect every parameter present in the wParam". I recall that, for $LVM_SETEXTENDEDLISTVIEWSTYLE, wParam is a mask:

  • if a bit in wParam is a 1, Windows looks at the corresponding bit in lParam. If this bit is a 1, it is set in Windows, else it is reset
  • If a bit in wParam is a 0, Windows ignores the bit in lParam.
So $n,$n sets only the lvs_ex styles that are in $n.

I see that http://msdn.microsoft.com/en-us/library/windows/desktop/bb774732%28v=vs.85%29.aspx, Extended List-View Styles (Windows), says:

Use the LVM_SETEXTENDEDLISTVIEWSTYLE message or one of the ListView_SetExtendedListViewStyle or ListView_SetExtendedListViewStyleEx macros to employ these extended list-view control styles.

That's why I am using GuiCtrlSendMsg to send LVS_EX constants.

I note that there are LVS_EX constants that have the same value as WS_EX constants. For example: LVS_EX_REGIONAL and WS_EX_CLIENTEDGE, LVS_EX_UNDERLINECOLD and WS_EX_RIGHT. So (as for simpler controls), the exStyle parameter of GuiCtrlCreateListView() is for WS_EX constants, and LVS_EX constants have to be sent using GuiCtrlSendMsg. Otherwise, how can Windows know whether you mean, for example, LVS_EX_UNDERLINECOLD or WS_EX_RIGHT?

I do see that I have an error in my exStyle parameter: per the last paragraph, LVS_EX_FULLROWSELECT should not be there. But when I remove it, my test script still doesn't uncheck the box. (WS_EX_TRANSPARENT has the same value as LVS_EX_FULLROWSELECT.)

So we have a case where what I understand to be incorrect code works, but the code I believe fits with MSDN doesn't! Go figure!

Your further thoughts are most welcome.

Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Link to comment
Share on other sites

the exStyle parameter of GuiCtrlCreateListView() is for WS_EX constants, and LVS_EX constants have to be sent using GuiCtrlSendMsg

how can Windows know whether you mean, for example, LVS_EX_UNDERLINECOLD or WS_EX_RIGHT

The Style which is affected by the same value would do the work in both the cases

if still not satisfied

look at

  • _GUICtrlListView_SetExtendedListViewStyle
  • GUICtrlSetStyle

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

The value of LVS_EX_UNDERLINECOLD, and of WS_EX_RIGHT, is 0x1000. The answer to my question (which I thought was rhetorical) is:

  • when Windows sees ox1000 in th exStyle parameter, it knows it is ES_EX_RIGHT;
  • when Windows sees 0x1000,0x1000 in a SETEXTENDEDLISTVIEW message, it knows it is LVS_EX_UNDERLINECOLD.
BTW I see that _GUICtrlListView_SetExtendedListViewStyle does GuiCtrlSendMessage(SETEXTENDEDLISTVIEW, ...) Edited by c.haslam
Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

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