topten Posted November 17, 2015 Posted November 17, 2015 I am writing a function for dynamic creating guis. Here's a piece of code from the script Global $guiscounter = 0 Global $DynGui[10000] Global $DynPic[10000] $guiscounter=$guiscounter+1 Global $DynGui[$guiscounter] = GUICreate("GDI+ Example23 (" & @ScriptName & ")", $iWidth, $iHeight, $WS_POPUP) DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($DynGui[$guiscounter]), "hwnd", WinGetHandle($Child1_GUI)) GUISetBkColor($iBgColor, $DynGui[$guiscounter]) ;set GUI background color Global $DynPic[$guiscounter] = GUICtrlCreatePic("", 0, 0, $iWidth, $iHeight) GUISetState(@SW_SHOW)I get an error==> Subscript used on non-accessible variable.:DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($DynGui[$guiscounter]), "hwnd", WinGetHandle($Child1_GUI))DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($DynGui^ ERRORIs the error happening because I am trying to WinGetHandle the dynamic gui?Great thanx in advance
Trong Posted November 17, 2015 Posted November 17, 2015 I do not know, try it:#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ColorConstantS.au3> Global $guiscounter = 0 Local $iWidth=800 Local $iHeight=600 Local $iBgColor=$COLOR_RED Global $DynGui = GUICreate("GDI+ Example23 (" & @ScriptName & ")", $iWidth, $iHeight, -1,-1, $WS_POPUP) DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($DynGui), "hwnd", WinGetHandle($DynGui)) GUISetBkColor($iBgColor, $DynGui) ;set GUI background color Global $DynPic = GUICtrlCreatePic("", 0, 0, $iWidth, $iHeight) GUISetState(@SW_SHOW) Sleep(3000) Enjoy my work? Buy me a 🍻 or tip via ❤️ PayPal
topten Posted November 17, 2015 Author Posted November 17, 2015 Trong, thank you very muchI know this code. This works ok. But when I am trying to make the variable dynamic, then it breaks though!
JohnOne Posted November 17, 2015 Posted November 17, 2015 No, it is reporting that $DynGui[$guiscounter] is outside the bounds of the array $DynGui. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
topten Posted November 17, 2015 Author Posted November 17, 2015 Aha, butIt doesnt give error for this part, which is supposed to beGlobal $DynGui[$guiscounter] = GUICreate("GDI+ Example23 (" & @ScriptName & ")", $iWidth, $iHeight, $WS_POPUP)But gives error for this part DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($DynGui[$guiscounter]), "hwnd", WinGetHandle($Child1_GUI))Looks like DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($DynGui[1]), "hwnd", WinGetHandle($Child1_GUI))wont work
LarsJ Posted November 17, 2015 Posted November 17, 2015 I think this line is a ReDim of your array to just one row:Global $DynGui[$guiscounter] = GUICreate("GDI+ Example23 (" & @ScriptName & ")", $iWidth, $iHeight, $WS_POPUP)You can access this row through index zero. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions
water Posted November 17, 2015 Posted November 17, 2015 (edited) Remove the GlobalGlobal $guiscounter = 0 Global $DynGui[10000] Global $DynPic[10000] $guiscounter=$guiscounter+1 $DynGui[$guiscounter] = GUICreate("GDI+ Example23 (" & @ScriptName & ")", $iWidth, $iHeight, $WS_POPUP) DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($DynGui[$guiscounter]), "hwnd", WinGetHandle($Child1_GUI)) GUISetBkColor($iBgColor, $DynGui[$guiscounter]) ;set GUI background color $DynPic[$guiscounter] = GUICtrlCreatePic("", 0, 0, $iWidth, $iHeight) GUISetState(@SW_SHOW) Edited November 17, 2015 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted November 17, 2015 Posted November 17, 2015 I do not know if this is intended:GUICtrlCreatePic overwrites the handle for GUICreate because you didn't increment $guiscounter. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
topten Posted November 17, 2015 Author Posted November 17, 2015 @ Water, as You say "GUICtrlCreatePic overwrites the handle for GUICreate because you didn't increment $guiscounter."$DynGui[$guiscounter] = GUICreate("GDI+ Example23 (" & @ScriptName & ")", $iWidth, $iHeight, $WS_POPUP)$DynPic[$guiscounter] = GUICtrlCreatePic("", 0, 0, $iWidth, $iHeight)How? I was thinking that $DynGui[$guiscounter] will be for GUI and $DynPic[$guiscounter] will be for PIC .
water Posted November 17, 2015 Posted November 17, 2015 Ops, you are correct. My fault My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now