Sign in to follow this  
Followers 0
sohfeyr

_GUICtrlListView... crashing target app

17 posts in this topic

I have a two-fold frustration.

The first I think is a problem for gafrost, but I'm open to any ideas:

When I use certain _GUICtrlListView commands, it causes the target application to crash.

In case it matters, I'm running Windows XP Home SP2 on an AMD Turion 64.

Sample app:

#include <GUIListView.au3> ; includes ListViewConstants and Array

$winHWnd=CWL("Window Handle:",WinGetHandle("My Documents"))
$lvwHWnd=CWL("Lstview Handle:",ControlGetHandle($winHWnd,"","SysListView321"))
CWL("LV Backcolor:",_GUICtrlListViewGetBackColor($lvwHWnd))
CWL("Callback Mask:",_GUICtrlListViewGetCallBackMask($lvwHWnd))
CWL("Col 1 Width:",_GUICtrlListViewGetColumnWidth($lvwHWnd,1))
CWL("Counter Page:",_GUICtrlListViewGetCounterPage($lvwHWnd))
CWL("Header Handle:",HWnd(_GUICtrlListViewGetHeader($lvwHWnd)))
CWL("Item Count:",_GUICtrlListViewGetItemCount($lvwHWnd))
; Crashes Target App --> CWL("Column Order:",_GUICtrlListViewGetColumnOrder($lvwHWnd))
CWL("Current Slxn:",_GUICtrlListViewGetCurSel($lvwHWnd))
CWL("ExtLVStyle:",Hex(_GUICtrlListViewGetExtendedListViewStyle($lvwHWnd)))
CWL("Subitems Count:",_GUICtrlListViewGetSubItemsCount($lvwHWnd))
; Crashes Target App --> CWL("Item 19 Text:",_GUICtrlListViewGetItemText($lvwHWnd,19))
; Crashes Target App --> _GUICtrlListViewSetColumnHeaderText($lvwHWnd,2,"changed")

Func CWL($d1, $d2="", $d3="", $d4="", $d5="", $d6="", $d7="", $d8="", $d9="", $d10="")
    ConsoleWrite($d1)
    For $i = 2 to @NumParams
        ConsoleWrite(@tab & Eval("d" & $i))
    Next
    ConsoleWrite(@crlf)
    Return $d2
EndFunc

Obviously my ultimate goal is not to read the contents of "My Documents", but another listview in another app we test at my workplace, so no file system workarounds please.

Share this post


Link to post
Share on other sites



well i would just like to say that i had this problem with _GUICtrlListSort

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

HAHAH no the script i was writing i stopped cuz i didnt need it anymore so nope :-/

Share this post


Link to post
Share on other sites

Wow, with all the listview talk I really expected more people to jump on this one with their own experiences... surely someone else has noticed this?

Really, if I can get the text and rect of the listview column header, I'll be thrilled. All the other commands I foresee needing work...

Anyone?

Share this post


Link to post
Share on other sites

Does it work if you don't call CWL? Meaning, try changing the first crashy line to:

_GUICtrlListViewGetColumnOrder($lvwHWnd)
I know you won't get your testing info, I'm just trying to take out potential factors.


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

Does it work if you don't call CWL? Meaning, try changing the first crashy line to:

_GUICtrlListViewGetColumnOrder($lvwHWnd)
I know you won't get your testing info, I'm just trying to take out potential factors.
No, it doesn't work if CWL isn't called. You just have no idea where it failed.

Share this post


Link to post
Share on other sites

Sorry to go over the basic stuff, but have you updated to the latest version of AutoIt and the Beta? Tried uninstalling and reinstalling both? Tried it on different machines and operating stations?


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

This is a hunch, but put sleep(1000) as the first command in CWL. Each window has a window message queue, maybe your calls are stepping on each other...


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

This is a hunch, but put sleep(1000) as the first command in CWL. Each window has a window message queue, maybe your calls are stepping on each other...

That's a nice thought, but I did try each command in isolation. Moreover, the commands use SendMessage(), which is synchronous - it doesn't return until there is a response.

Yes I am using the latest. As to trying on different systems / OSes, this ultimately needs to run on any machine it's tried with, not just the one I use for development. If it doesn't work on that, though, it's too unreliable to trust on the others.

Have you tried running these? Do they work for you?

Share this post


Link to post
Share on other sites

That's a nice thought, but I did try each command in isolation. Moreover, the commands use SendMessage(), which is synchronous - it doesn't return until there is a response.

Yes I am using the latest. As to trying on different systems / OSes, this ultimately needs to run on any machine it's tried with, not just the one I use for development. If it doesn't work on that, though, it's too unreliable to trust on the others.

Have you tried running these? Do they work for you?

Some of these functions were not tested outside of AutoIt, they appear to work fine in applications.

The ones crashing explorer all have a ptr in them.

All the other commands I foresee needing work...

Now If you can make re-write them and make them work with explorer have at it.

I'll keep trying when I have time, but please refran from making assumptions.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

I'll keep trying when I have time, but please refran from making assumptions.

Ok. Please understand I wasn't implying anything - I really admire all that I've seen from you, gafrost.

What is the significance that the ones crashing explorer all have a ptr in them?

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Ok. Please understand I wasn't implying anything - I really admire all that I've seen from you, gafrost.

What is the significance that the ones crashing explorer all have a ptr in them?

yes a ptr, which is wierd because i can take the examples and get the handle to the listview and use that and it works fine, so maybe the ones tied into explorer are different somehow. not sure.

Edit: btw i tried on win2k on my vpc and had the same problems with the same functions, so it's not just a win xp problem.

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

yes a ptr, which is wierd because i can take the examples and get the handle to the listview and use that and it works fine, so maybe the ones tied into explorer are different somehow. not sure.

Edit: btw i tried on win2k on my vpc and had the same problems with the same functions, so it's not just a win xp problem.

I have the similar problem and my applicaiton crash and my solution is make a small script to keep on press the button "continue" of the error window and everything is normal.

Share this post


Link to post
Share on other sites

a quick workaround for now untill can figure out why explorer is not likeing the udf's would be to use ControlListView

i.e.

ConsoleWrite(_GetListViewText("My Documents", "", "SysListView321", 19) & @LF)

Func _GetListViewText($sTitle, $sText, $sControl, $index)
    Local $s_text, $i_subcount = ControlListView($sTitle, $sText, $sControl, "GetSubItemCount")
    For $x = 0 To $i_subcount -1
        $s_text &= ControlListView($sTitle, $sText, $sControl, "GetText", $index, $x) & "|"
    Next
    Return StringTrimRight($s_text, 1)
EndFunc

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

I appreciate the thought, and I'll definitely keep that function around, but it doesn't really do what I want... I'm trying to get the text from the header itself.

I did follow the general direction of your advice to manage a workaround for getting the location, though:

#include <GUIListView.au3>

Const $HDM_FIRST = 0x1200
Const $HDM_GETITEMCOUNT = ($HDM_FIRST + 0)
Const $HDM_ORDERTOINDEX = ($HDM_FIRST + 15)
Const $HDM_GETORDERARRAY = ($HDM_FIRST + 17)

; see CWL function in previous post
cwl("Header 0 rect:", HeaderGetItemRect2($lvwHWnd,0))
cwl("Header 1 rect:", HeaderGetItemRect2($lvwHWnd,1))
cwl("Header 2 rect:", HeaderGetItemRect2($lvwHWnd,2))
cwl("Header 3 rect:", HeaderGetItemRect2($lvwHWnd,3))
cwl("Header n rect:", HeaderGetItemRect2($lvwHWnd,65532))

Func HeaderGetItemRect2($h_listview, $i_index) ; Works
    Local $h_header = HWnd(_GUICtrlListViewGetHeader($h_listview))
    Local $CGP=ControlGetPos("","",$h_header)
    Local $left = $CGP[0]
    Local $top = $CGP[1]
    Local $right = $left + _GUICtrlListViewGetColumnWidth($h_listview,0)
    Local $height = $CGP[3]
    Dim $col
    For $col in HeaderGetOrderArray($h_header) ; array of integers
        $left = $right
        $right = $left + _GUICtrlListViewGetColumnWidth($h_listview,$col)
        If $col = $i_index then ExitLoop
    Next
    Local $width = $right-$left
    Return _ArrayCreate($left, $top, $width, $height)
EndFunc

Func HeaderGetOrderArray($h_header)  ; Works
    $max=HeaderGetItemCount($h_header)
    ; This mechanism causes a security exception in the target app. Fortunately, there is a workaround.
    ;       $ord=DllStructCreate("int[" & $max & "]")
    ;       $ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_header, "int", $HDM_GETORDERARRAY, "int", $max, "ptr", DllStructGetPtr($ord))
    Dim $ord[$max]
    For $i_order=0 to $max-1
        $ord[$i_order]=HeaderOrderToIndex($h_header,$i_order)
    Next
    Return $ord
EndFunc

Func HeaderOrderToIndex($h_header, $i_order) ; Works
    If $i_order>HeaderGetItemCount($h_header) or $i_order<0 then return -1
    $ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_header, "int", $HDM_ORDERTOINDEX, "int", $i_order, "int", 0)
    If IsArray($ret) Then Return $ret[0]
    Return -1
EndFunc

Func HeaderGetItemCount($h_header) ; Works
    $ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_header, "int", $HDM_GETITEMCOUNT, "int", 0, "int", 0)
    If IsArray($ret) Then Return $ret[0]
    Return -1
EndFunc

Still no luck with text, I'm afraid... Hopefully the above code will inspire someone, or at least prove useful.

Edit: forgot the consts!

Edited by sohfeyr

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