Jump to content

Can't access array with _WM_COMMAND


Recommended Posts

I have a complete error with array when i'm clicked in button, array error ( can't use _ArrayDiplay() )

All function return an array will same be error, autoit crash with msgbox

 

#include <Array.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Window", 500, 400, -1, -1)
$hButton = GUICtrlCreateButton("CRASH!", 126, 103, 278, 129)
GUICtrlSetFont(-1, 20, 800, 0)
GUISetState()

GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")

While 1
    $hMsg = GUIGetMsg()
    Switch $hMsg
        Case -3
            Exit
    EndSwitch
WEnd

Func _WM_COMMAND($hWnd, $Msg, $wparam, $lparam)
If BitAND($wparam, 0x0000FFFF) = $hButton Then

    EndIf

    Dim $a = [1,2,3,4,5,6]
    _ArrayDisplay($a)

    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_COMMAND

 

Link to post
Share on other sites

From AutoIt help file > GUIRegisterMsg function > Remarks :- "Warning: blocking of running user functions which executes window messages with commands such as "MsgBox()" can lead to unexpected behavior, the return to the system should be as fast as possible !!!"

Along with "MsgBox()", you can include "_ArrayDisplay()".

#include <Array.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>

Global $a
$hGUI = GUICreate("Window", 500, 400, -1, -1)
$hButton = GUICtrlCreateButton("Button!", 126, 103, 278, 129)
GUICtrlSetFont(-1, 20, 800, 0)
GUISetState()

GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")
ConsoleWrite("$hButton  " & $hButton & @CRLF)
While 1
    $hMsg = GUIGetMsg()
    Switch $hMsg
        Case -3
            Exit
        Case $hButton
            _ArrayDisplay($a)

    EndSwitch
WEnd

Func _WM_COMMAND($hWnd, $Msg, $wparam, $lparam)
    If BitAND($wparam, 0x0000FFFF) = $hButton Then
        Dim $a = [1, 2, 3, 4, 5, 6]
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_COMMAND

 

Edited by Malkey
Link to post
Share on other sites
16 hours ago, Malkey said:

From AutoIt help file > GUIRegisterMsg function > Remarks :- "Warning: blocking of running user functions which executes window messages with commands such as "MsgBox()" can lead to unexpected behavior, the return to the system should be as fast as possible !!!"

Along with "MsgBox()", you can include "_ArrayDisplay()".

Thank you, i have a mistake with Remarks :D

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...