pdaughe Posted May 20, 2007 Share Posted May 20, 2007 I have a loop which looks at control ids. The following statement: If BitAND (GUICtrlGetState ($Control_ID), $GUI_HIDE) Then ContinueLoop appears in the body of the loop to ignore a control if it is hidden. The loop is driven by a mouse move event. In AutoIt 3.2.3.2 the IF condition did NOT test true for a ListView control when it was not hidden. In AutoIt 3.2.4.5 the IF condition ALWAYS test true for a ListView control. Looking at the documentation for GUICtrlGetState, it seems I was not using GUICtrlGetState correctly, due to this note in the remarks: Exceptions: For ListView controls it returns the number of the clicked column. Oops. The question now is: How does one reliably test the state of a control, not knowing the type of the control? If GUICtrlSetState is used to disable a ListView control, how do you test the state of the control? Link to comment Share on other sites More sharing options...
Zedna Posted May 20, 2007 Share Posted May 20, 2007 Correct way is: If BitAND (GUICtrlGetState ($Control_ID), $GUI_HIDE) = $GUI_HIDE Then ContinueLoop Because your control can have more than one style. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
pdaughe Posted May 20, 2007 Author Share Posted May 20, 2007 Correct way is: If BitAND (GUICtrlGetState ($Control_ID), $GUI_HIDE) = $GUI_HIDE Then ContinueLoop Because your control can have more than one style.I agree the above code is "better" (actually surprised I wrote it the way I did) in that it does not imply knowledge that the possible set of tested values are bit-oriented. In the case of styles/states, the values are bit-oriented (i.e. you BitOR styles as opposed to adding them) so only one or none of the bits is going to be on in the result. I changed it anyway and it still always tests true for a ListView control in !!3.2.4.6!! Thank you for your response. If I'm not thinking correctly, please tell me so -- it's been a long weekend! Sincerely, Paul Link to comment Share on other sites More sharing options...
pdaughe Posted May 20, 2007 Author Share Posted May 20, 2007 A work-around for this is to borrow a statement from the Listview functions: IF _IsClassName ($h_Source_listview, "SysListView32") Then Ingore test for disabled control I still don't know how one would test for a disabled control though.... Link to comment Share on other sites More sharing options...
pdaughe Posted May 22, 2007 Author Share Posted May 22, 2007 A developer may want to take a look at this. Even though the documentation does state: Exceptions: For ListView controls it returns the number of the clicked column. it seems to me to be an unfortunate inconsistency. Even though I have a work-around, there may be cases where someone would need to test the state of a listview control. I still don't know how to check if a listview control is enabled? Link to comment Share on other sites More sharing options...
GaryFrost Posted May 22, 2007 Share Posted May 22, 2007 Example: ConsoleWrite(ControlCommand("ListView Delete All Items","","SysListView321","IsEnabled", "") & @LF) GUICtrlSetState($listview, $GUI_DISABLE) ConsoleWrite(ControlCommand("ListView Delete All Items","","SysListView321","IsEnabled", "") & @LF) SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
pdaughe Posted May 22, 2007 Author Share Posted May 22, 2007 Thanks Gary! Link to comment Share on other sites More sharing options...
pdaughe Posted May 28, 2007 Author Share Posted May 28, 2007 I agree the above code is "better" (actually surprised I wrote it the way I did) in that it does not imply knowledge that the possible set of tested values are bit-oriented. In the case of styles/states, the values are bit-oriented (i.e. you BitOR styles as opposed to adding them) so only one or none of the bits is going to be on in the result. I changed it anyway and it still always tests true for a ListView control in !!3.2.4.6!! Thank you for your response. If I'm not thinking correctly, please tell me so -- it's been a long weekend! Sincerely, PaulThe above reply (by me) was in response to the previous reply by Zedna. I believe Zedna's reply was CORRECT, and my reply was incorrect. It appears from the AutoIt documentation that CONTROL styles can be summed up, whereas Window styles may not, implying Window styles are indeed bit-oriented, but NOT control styles as I stated. Therefore, writing: If BitAND (GUICtrlGetState ($Control_ID), $GUI_HIDE) Then ContinueLoopoÝ÷ ØÚ-zØZµ«¢+Ù%9½Ð ¥Ñ9¡]¥¹ÑMÑÑ ÀÌØíAÉ´¤°È¤Q¡¸IÑÕɸ±Í IS valid because Window styles are bit-oriented. I point this out because I appreciate this forum and the last thing I would want to do is mislead someone or state something with affirmation that is incorrect. The original point of this thread is that: GUICtrlGetState ($Control_ID), $GUI_HIDE) = $GUI_HIDE is an invalid test if the control_ID identifies a listview control. This IS stated in the AutoIt documentation. Sincerely, Paul 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