Jump to content
Sign in to follow this  
Sascha

GUIRegisterMsg and ArrayDisplay hangs

Recommended Posts

Sascha

Hello together,

the following code hangs when calling the ArrayDisplay function.

Any ideas why?

CODE
#include <Array.au3>

#include "constants.au3"

#include <GUIConstants.au3>

#include <WindowsConstants.au3>

$Form1 = GUICreate("Protokollchecker", 277, 76, 390, 283, -1, BitOR($WS_EX_ACCEPTFILES,$WS_EX_WINDOWEDGE))

$btnOpenProt = GUICtrlCreateButton("Protokoll öffnen", 168, 24, 91, 25, 0)

GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_COMMAND, "On_WM_ButtonCheckProt")

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

Func On_WM_ButtonCheckProt($hWnd, $Msg, $wParam, $lParam)

$nID = BitAND($wParam, 0x0000FFFF)

if $nID = $btnOpenProt Then

Local $array[10]

$array[1] = "A"

_ArrayDisplay($array)

EndIf

EndFunc

Func On_WM_DragAndDrop($hWnd, $Msg, $wParam, $lParam)

EndFunc

Regards

Sascha

Share this post


Link to post
Share on other sites
foster74

From help file:

"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 !!!"

If GUIRegisterMsg() is not needed, maybe look at OnEventMode? Or if needed, have the _ArrayDisplay outside of the function.

Share this post


Link to post
Share on other sites
Sascha

From help file:

return to the system should be as fast as possible !!!"

Thank you.

The only quick way to go around this was to set boolean flag in the the message function.

I now call my method from within the message loop if the flags are set.

My solution seems a little bit dirty to me but works

Share this post


Link to post
Share on other sites
jvanegmond

You can also copy the function _ArrayDisplay from Array.au3 include and modify it to be a non-blocking function.

Share this post


Link to post
Share on other sites
KaFu

The only quick way to go around this was to set boolean flag in the the message function.

I now call my method from within the message loop if the flags are set.

My solution seems a little bit dirty to me but works

Dirty? Is it? Don't think so... I do this all the time :P, to have them available at (near) runtime call the results via a timer.

Share this post


Link to post
Share on other sites
jvanegmond

Dirty? Is it? Don't think so... I do this all the time :P, to have them available at (near) runtime call the results via a timer.

Just because you do it all the time doesn't mean it is not dirty. :unsure:

Share this post


Link to post
Share on other sites
KaFu

Just because you do it all the time doesn't mean it is not dirty. :unsure:

Touchee :P, true most of the time :D, but in my eyes thats how WMs should be treated. Check state, set vars and do the work at another point in your script. Can't see anything dirty about the usage of Global booleans to do this.

The return to the system should be as fast as possible !!!

Share this post


Link to post
Share on other sites
jvanegmond

Touchee :P, true most of the time :D, but in my eyes thats how WMs should be treated. Check state, set vars and do the work at another point in your script. Can't see anything dirty about the usage of Global booleans to do this.

Yes, I agree. It would be nice here to have some object oriented syntax, but whatever. :unsure:

Share this post


Link to post
Share on other sites
Sascha

Dirty? Is it? Don't think so... I do this all the time :P, to have them available at (near) runtime call the results via a timer.

In a multithreaded C++ application the use boolean flags as semaphores will (can) lead to chaos. Thats why i thinks it is not so clean.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.