Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Why is Scripting.Dictionary.Add(hwnd) munging its reference?

$
0
0
I am posting this to get information on other gotchas like this... what shouldn't I be passing to a dictionary?

[ autoit ]         
#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> global $gc_oForms=ObjCreate("Scripting.Dictionary") global $make_error_happen=false $make_error_happen=true ; Example shows destruction of hwnd by passing it to a dictionary object .Add, evidently by ref ; Is there something to know about handles and dictionaries? ; Example1() ; example 1 Func Example1() Local $msg ; local $hGui=GUICreate("My GUI") ; will create a dialog box that when displayed is centered ;A valid hwnd MsgBox(0,'Handle1',$hGui) if $make_error_happen Then      ;pass handle directly which will mung the $hGui variable up      $gc_oForms.Add('stuff',$hGui)      ;$hGui is invalid now, has been transformed - Autoit at fault or Dictionary?      MsgBox(0,'Handle2',$hGui)      MsgBox(0,'Handle3',$gc_oForms.Item('stuff')) endif local $cid=GUICtrlCreateButton("Darn Button",0,0) ;if $make_error_happen then this next call fails local $p=ControlGetPos($hGui, "", $cid );xywh if @error then      MsgBox(0,"ERROR HERE",'@error:'&@error) endif ; GUISetState(@SW_SHOW) ; will display an empty dialog box ; Run the GUI until the dialog is closed While 1      $msg = GUIGetMsg()      If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete() EndFunc ;==>Example1

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>