Jump to content

_ArrayDisplay() and MsgBox() at same time


Recommended Posts

Hi everyone :)
I wanted to display a Msgbox (with Retry/Cancel options) while _ArrayDisplay() is being shown.
This allows the user to choose an option, with a complete error message in Msgbox, while he can analyze the results in the _ArrayDisplay() window, scroll into it etc...

To try this, this is a quick script I prepared, unfinished, but you got the idea :

#include <Array.au3>
#include <MsgBoxConstants.au3>

Global $aArray[4] = ["element 0", "element 4", "element 2", "element 3"]

AdlibRegister("MyAdLibFunc", 500) ; each half second (500ms)
_ArrayDisplay($aArray, "Elements")
AdlibUnRegister("MyAdLibFunc")

Func MyAdLibFunc()
    If WinExists("Elements") Then
        AdlibUnRegister("MyAdLibFunc")
        MsgBox(BitOr($MB_TOPMOST, $MB_RETRYCANCEL), "Error in Array", _
            "Element 4 shouldn't be placed in Row 1")
        WinClose("Elements")
    EndIf
EndFunc   ;==>MyAdLibFunc

5c45d33d2f94a_2sametime.jpg.ddbca58332be0beaebc4e488d446eff1.jpg


Is there another easy way you're thinking of, instead of using AdlibRegister ?
(though it shouldn't consume too much CPU load as it's called each half second)
Thanks

Edited by pixelsearch
Link to post
Share on other sites

Don't use _ArrayDisplay for this, create your own listview. _ArrayDisplay is a blocking function and should only be used for troubleshooting an array's contents. If you want your script to do other things while displaying the contents of an array without using a workaround, you should build it yourself.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to post
Share on other sites

Try this:

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7

#pragma compile(AutoItExecuteAllowed, True)

Opt( "MustDeclareVars", 1 )

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

Example()

Func Example()
  Local $hGui = GUICreate( "My GUI", 250, 100 )

  GUIRegisterMsg( $WM_USER, "WM_USER" )
  Local $sMbTitle = "Error in Array", $sMbText = "Element 4 shouldn't be placed in Row 1"
  Run( @AutoItExe & ' /AutoIt3ExecuteLine "DllCall(''user32.dll'', ''lresult'', ''SendMessageW'', ''hwnd'', ""' & $hGui & '"", ''uint'', ""' & $WM_USER & '"", ''wparam'', ""' & 0 & '"", ''lparam'', MsgBox( ""' & $MB_TOPMOST+$MB_RETRYCANCEL & '"", ""' & $sMbTitle & '"", ""' & $sMbText & '"" ))"' )

  GUISetState()

  Local $aArray = ["element 0", "element 4", "element 2", "element 3"]
  _ArrayDisplay( $aArray )

  While 1
    Switch GUIGetMsg()
      Case $GUI_EVENT_CLOSE
        ExitLoop
    EndSwitch
  WEnd

  GUIDelete( $hGui )
EndFunc

Func WM_USER( $hWnd, $iMsg, $wParam, $lParam )
  Switch $lParam
    Case $IDCANCEL
      ConsoleWrite( "MsgBox Cancel" & @CRLF )
    Case $IDRETRY
      ConsoleWrite( "MsgBox Retry" & @CRLF )
  EndSwitch
  #forceref $hWnd, $iMsg, $wParam
EndFunc

 

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...