Sign in to follow this  
Followers 0
katoNkatoNK

Controls dissapear and menu item's swap menu's..

17 posts in this topic

#1 ·  Posted (edited)

Hi Melba23

I hope you can help me once again :huh2:

I have the same problem as Lupo73 had before you updated the UDF, except i'm getting the same error while renewing dynamic menu items..so it has to delete the controls then recreate them.

$iAdjust_Y = $aPos[1] - $iNext_Coord
$iAdjust_Y = $aPos^ ERROR

KatoNK..

Edited by katoNkatoNK

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

katoNkatoNK,

Perhaps if you posted some code so I could take a look...... :huh2:

M23

Edit: Does this do what you want - you do need to create dummy controls for all possible menu items when the menu is first created and keep those entries in the ControlID array filled when you delete the menuitem. This takes advantage of the fact that Autoit uses the first available entry in the array and you keep filling the same elements: :alien:

#include <GUIConstantsEx.au3>
#include "GUIExtender.au3"

$hGUI = GUICreate("Test", 500, 500)

$mMenu = GUICtrlCreateMenu("File")

$mTest1Item = GUICtrlCreateMenuItem("Test 1", $mMenu)
$mTest2Item = GUICtrlCreateDummy() ; Placeholder for later menuitem
$mTest3Item = GUICtrlCreateDummy() ; Placeholder for later menuitem
$mExitItem = GUICtrlCreateMenuItem("Exit", $mMenu)

_GUIExtender_Init($hGUI)

_GUIExtender_Section_Start(0, 100)
$hButton = GUICtrlCreateButton("Change to 2 + 3", 10, 10, 100, 30)
_GUIExtender_Section_End()

$iExt = _GUIExtender_Section_Start(100, 400)
$hLabel = GUICtrlCreateLabel("", 0, 100, 500, 400)
GUICtrlSetBkColor(-1, 0xFF0000)
_GUIExtender_Section_End()

_GUIExtender_Section_Action($iExt, "", "", 470, 10, 15, 15) ; Normal button

GUISetState()

While 1

    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            Switch GUICtrlRead($hButton)
                Case "Change to 2 + 3"
                    ; Delete
                    GUICtrlDelete($mTest1Item) ; Delete menuitem
                    $mTest1Item = GUICtrlCreateDummy() ; Fill with placeholder
                    GUICtrlDelete($mTest2Item) ; Delete placeholder
                    GUICtrlDelete($mTest3Item) ; Delete placeholder
                    $mTest2Item = GUICtrlCreateMenuItem("Test 2", $mMenu, 0) ; Create new menuitem
                    ConsoleWrite("2 = " & $mTest2Item & @CRLF) ; Just to prove the ControlID is retained
                    $mTest3Item = GUICtrlCreateMenuItem("Test 3", $mMenu, 1) ; Create new menuitem
                    ConsoleWrite("3 = " & $mTest3Item & @CRLF) ; Just to prove the ControlID is retained
                    GUICtrlSetData($hButton, "Change to 1")
                Case "Change to 1"
                    GUICtrlDelete($mTest2Item) ; Delete menuitem
                    GUICtrlDelete($mTest3Item) ; Delete menuitem
                    $mTest2Item = GUICtrlCreateDummy() ; Fill with placeholder
                    $mTest3Item = GUICtrlCreateDummy() ; Fill with placeholder
                    GUICtrlDelete($mTest1Item) ; Delete placeholder
                    $mTest1Item = GUICtrlCreateMenuItem("Test 1", $mMenu, 0) ; Create new menuitem
                    ConsoleWrite("1 = " & $mTest1Item & @CRLF) ; Just to prove the ControlID is retained
                    GUICtrlSetData($hButton, "Change to 2 + 3")
            EndSwitch
    EndSwitch
    _GUIExtender_Action($iMsg)

WEnd

Any help? ;)

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hi, i've cleaned up some code to show a replicator.. but after cleaning it up it seemed to work just fine, so here's the code maybe you can pick something from it while i have another look at the full script to see if i've missed anything.. The _SetMenuItem function is slightly tweaked by me but an example from guinness, so i doubt it would be causing any problems.. :huh2:

(In the full script the problem was deleting labels from the gui or giving the Coordinate error, and once or twice it's triggered a menu item and kept on looping it..)

#include <GUIConstantsEx.au3>
#include "GUIExtender.au3"

Opt('MustDeclareVars', 1)

Global $cFile = @ScriptDir & "\test.txt", $aSectionNames = IniReadSectionNames($cFile), $iLoad[1][2] = [[0, 2]], $iDelete[1][2] = [[0, 2]], $iCurrent, $iNew, $iLast
Global $hGUI, $Menu, $Load, $Delete, $Label, $sLoad, $sDelete, $Static1, $Section1, $Static2, $Section2, $iMsg

$hGUI = GUICreate("LazyIP", 200, 250, -1, -1)
$Menu = GUICtrlCreateMenu("Menu")
$Load = GUICtrlCreateMenu("Load", $Menu)
$Delete = GUICtrlCreateMenu("Delete", $Menu)

_GUIExtender_Init($hGUI)

$Static1 = _GUIExtender_Section_Start(0, 100)
GUICtrlCreateLabel("Label 1:", 20, 10)
GUICtrlCreateLabel("Label 2:", 20, 30)
GUICtrlCreateLabel("Label 3:", 20, 50)
$Label = GUICtrlCreateLabel("", 70, 50, 100, 15)
GUICtrlCreateLabel("Section 1", 35, 85)
_GUIExtender_Section_Action($Static1 + 1, "", "", 13, 85, 15, 15)
_GUIExtender_Section_End()

$Section1 = _GUIExtender_Section_Start(100, 50)
GUICtrlCreateLabel("", 0, 100, 200, 50)
GUICtrlSetBkColor(-1, 0xFFCCCC)
GUICtrlSetState(-1, $GUI_DISABLE)
_GUIExtender_Section_End()

$Static2 = _GUIExtender_Section_Start(150, 20)
GUICtrlCreateLabel("Section 2", 35, 150)
_GUIExtender_Section_Action($Static2 + 1, "", "", 13, 150, 15, 15)
_GUIExtender_Section_End()

$Section2 = _GUIExtender_Section_Start(170, 50)
GUICtrlCreateLabel("", 0, 170, 200, 50)
GUICtrlSetBkColor(-1, 0xFFCCCC)
GUICtrlSetState(-1, $GUI_DISABLE)
_GUIExtender_Section_End()

_GUIExtender_Section_Start(230, 30)
GUICtrlCreateLabel("", 0, 230, 200, 30)
_GUIExtender_Section_End()

_GUIExtender_Section_Extend(0, False)

If IsArray($aSectionNames) Then
    _SetMenuItems($iLoad, $iLoad, $aSectionNames, $Load)
    _SetMenuItems($iDelete, $iDelete, $aSectionNames, $Delete)
Else
    MsgBox(0, "", "No Sections found.")
EndIf

GUISetState(@SW_SHOW, $hGUI)
While 1
    $iMsg = GUIGetMsg()
    Global $Current_Label = GUICtrlRead($Label)

    _UpdateMenuItems($Load, $Delete)
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case Else
            If $iLoad[0][0] > 0 Then
                If $iMsg >= $iLoad[1][0] And $iMsg <= $iLoad[$iLoad[0][0]][0] Then
                    For $A = 1 To $iLoad[0][0]
                        If $iMsg = $iLoad[$A][0] Then
                            $sLoad = $iLoad[$A][1]
                            ExitLoop
                        EndIf
                    Next
                    _Load($sLoad)
                    If @error Then MsgBox(0, "", "Load error.")
                EndIf
            EndIf
            If $iDelete[0][0] > 0 Then
                If $iMsg >= $iDelete[1][0] And $iMsg <= $iDelete[$iDelete[0][0]][0] Then
                    For $A = 1 To $iDelete[0][0]
                        If $iMsg = $iDelete[$A][0] Then
                            $sDelete = $iDelete[$A][1]
                            ExitLoop
                        EndIf
                    Next
                    _Delete($sDelete)
                    ;If Not @error Then _UpdateMenuItems($Load, $Delete)
                EndIf
            EndIf
    EndSwitch
    _GUIExtender_Action($iMsg)
WEnd

Func _SetMenuItems(ByRef $aDeleteArray, ByRef $aCreateArray, ByRef $iArray, $hCtrl)
    If IsArray($aDeleteArray) Then
        For $A = 1 To $aDeleteArray[0][0]
            GUICtrlDelete($aDeleteArray[$A][0])
            $aDeleteArray[$A][0] = -1
        Next
    EndIf
    If IsArray($aCreateArray) And IsArray($iArray) Then
        ReDim $aCreateArray[$iArray[0] + 1][2]
        $aCreateArray[0][0] = $iArray[0]
        For $A = 1 To $aCreateArray[0][0]
            Local $iText = $iArray[$A]
            $aCreateArray[$A][0] = GUICtrlCreateMenuItem($iText, $hCtrl)
            $aCreateArray[$A][1] = $iText
        Next
    EndIf
    Return 1
EndFunc   ;==>_SetMenuItems

Func _UpdateMenuItems($hHandle1, $hHandle2)
    If FileExists($cFile) Then
        $iCurrent = IniReadSectionNames($cFile)
        $iNew = ""
        If IsArray($iCurrent) Then
            For $i = 1 To $iCurrent[0]
                $iNew = $iNew & $iCurrent[$i]
            Next
            If $iNew <> $iLast Then
                _SetMenuItems($iLoad, $iLoad, $iCurrent, $hHandle1)
                _SetMenuItems($iDelete, $iDelete, $iCurrent, $hHandle2)
                $iLast = ""
                For $i = 1 To $iCurrent[0]
                    $iLast = $iLast & $iCurrent[$i]
                Next
            Else
                Return
            EndIf
        Else
            $iCurrent = ""
            _SetMenuItems($iLoad, $iLoad, $iCurrent, $hHandle1)
            _SetMenuItems($iDelete, $iDelete, $iCurrent, $hHandle2)
        EndIf
    EndIf
EndFunc   ;==>_UpdateMenuItems

Func _Load($Load_Item)
    If FileExists($cFile) Then
        $aSectionNames = IniReadSectionNames($cFile)
        If IsArray($aSectionNames) Then
            GUICtrlSetData($Label, $Load_Item)
        Else
            MsgBox(0, "", "No Sections found.")
        EndIf
    Else
        Return SetError(1)
    EndIf
EndFunc   ;==>_Load

Func _Delete($Delete)
    If MsgBox(4, "Delete Preset", "Delete the following preset:" & @CRLF & $Delete) = 6 Then
        If $Delete = $Current_Label Then GUICtrlSetData($Label, "Label 3:")
        IniDelete($cFile, $Delete)
    EndIf
EndFunc   ;==>_Delete
Edited by katoNkatoNK

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

katoNkatoNK,

In the full script the problem was deleting labels from the gui

This is very likely to cause a problem. The UDF stores the ControlIDs of the first and last controls that are created between each _Section_Start and _Section_End call so that it knows which controls are on which section. If you delete a control froma section, or add another to it, once the script has started then the UDF will try to move the non-existent control (which is very likely to give an error) or fail to move the new one. :alien:

The fact that you are dynamically creating and deleting menuitems leads me to believe that you are indeed running into this problem. The solution is as I described above - create enough dummy controls to cater for the menuitems you will create and then swap the actual/dummy controls as you need. And rather than deleting existing labels on the GUI, just hide them - that way you do not cause the problem. :ph34r:

A little more explanation of why these measures will solve your problem. AutoIt stores its ControlIDs in an internal array - the ControlIDs are actually the indices of the array elements. When you delete a control you clear that element and when you create a control AutoIt looks for the first empty element to reuse. So deleting controls and then creating new ones will almost guarantee that the values stored by the UDF will be incorrect. The "trick" of creating dummy controls to act as placeholders means that when you delete and create in immediate succession you refill the same element of the internal array and so the UDF stored values remain valid. I hope that is now clear why labels were disappearing or menuitems being triggered as the script deleted and recreated controls - the new controls were almost certainly being recreated in elements of the ControlID array that the UDF believed were part of another section. :huh2:

I realise that you might not know in advance how many menu elements you are likely to have in your ini file which makes reserving places in the ControlID array a little difficult. I have an idea of how to solve this - let me work on it today. :)

M23

Edit:

I think I have a solution - you need to create the unknown number of menuitems after you have created all the permanent controls on the various sections of the GUI. That way you do not create holes in the ControlID array when you create/delete them. Similarly, you must not delete any existing controls on the GUI - you must HIDE/SHOW them so that there are no holes created in the ControlID array and the stored first/last ControlID for each section remains valid. ;)

This short script shows what I mean: :mad2:

#include <GUIConstantsEx.au3>
#include "GUIExtender.au3"

#include <Array.au3>

Global $cFile = @ScriptDir & "\test.txt", $aSectionNames, $iCount, $aLoad, $aDelete

$hGUI = GUICreate("Test", 500, 500)

$mMenu = GUICtrlCreateMenu("File")
$mLoad = GUICtrlCreateMenu("Load", $mMenu)
$mDelete = GUICtrlCreateMenu("Delete", $mMenu)
$mExit = GUICtrlCreateMenuItem("Exit", $mMenu)

_GUIExtender_Init($hGUI)

_GUIExtender_Section_Start(0, 110)
$hButton_1 = GUICtrlCreateButton("Clear Loaded Item", 10, 10, 100, 30)
$hLabel_1 = GUICtrlCreateLabel("Loaded item", 120, 10, 200, 30)
GUICtrlSetBkColor(-1, 0xFF0000)
_GUIExtender_Section_End()

$iExt = _GUIExtender_Section_Start(110, 390)
$hButton_2 = GUICtrlCreateButton("Hide Label", 10, 260, 100, 30)
$hLabel_2 = GUICtrlCreateLabel("This can be hidden", 120, 260, 200, 30)
GUICtrlSetBkColor(-1, 0xFF0000)
_GUIExtender_Section_End()

_GUIExtender_Section_Action($iExt, "", "", 470, 10, 15, 15) ; Normal button

_LoadMenu()

GUISetState()

While 1

    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE, $mExit
            Exit
        Case $hButton_1
            Switch GUICtrlRead($hButton_1)
                Case "Clear Loaded Item"
                    GUICtrlSetState($hLabel_1, $GUI_HIDE)
                    GUICtrlSetData($hButton_1, "Show Loaded Item")
                Case "Show Loaded Item"
                    GUICtrlSetState($hLabel_1, $GUI_SHOW)
                    GUICtrlSetData($hButton_1, "Clear Loaded Item")
            EndSwitch
        Case $hButton_2
            Switch GUICtrlRead($hButton_2)
                Case "Hide Label"
                    GUICtrlSetState($hLabel_2, $GUI_HIDE)
                    GUICtrlSetData($hButton_2, "Show Label")
                Case "Show Label"
                    GUICtrlSetState($hLabel_2, $GUI_SHOW)
                    GUICtrlSetData($hButton_2, "Hide Label")
            EndSwitch
        Case $aLoad[1] To $aLoad[$iCount]
            ; Set label to loaded element
            GUICtrlSetData($hLabel_1, GUICtrlRead($iMsg, 1))
        Case $aDelete[1] To $aDelete[$iCount]
            ; Delete selected element from ini file
            IniDelete($cFile, GUICtrlRead($iMsg, 1))
            ; Reload menus based on new ini file
            _LoadMenu()
    EndSwitch
    _GUIExtender_Action($iMsg)

WEnd

Func _LoadMenu()

    ; If we have menuitems then delete them
    If IsArray($aLoad) Then
        For $i = 1 To $iCount
            GUICtrlDelete($aLoad[$i])
            GUICtrlDelete($aDelete[$i])
        Next
    EndIf

    ; Reread the ini file
    $aSectionNames = IniReadSectionNames($cFile)

    ; And recreate the required menuitems
    $iCount = $aSectionNames[0]
    Global $aLoad[$iCount + 1], $aDelete[$iCount + 1]

    ; Note we have 2 loops so that the ControlIDs are in a single block for each array
    For $i = 1 To $iCount
        $aLoad[$i] = GUICtrlCreateMenuItem($aSectionNames[$i], $mLoad)
    Next

    For $i = 1 To $iCount
        $aDelete[$i] = GUICtrlCreateMenuItem($aSectionNames[$i], $mDelete)
    Next

EndFunc

I have also reduced the menu creation/deletion code a bit - I hope it still does what you want? :blink:

What have I overlooked? :(

M23

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hi Melba23

Just to clarify in case it makes a difference, the label's control ids are static and they are changed only using guictrlsetdata() and the only place that i am doing this is in the top static section.. would the showing/hiding of the labels make that much of a difference? (in my main script the menu items are being added as shown in your reply - after all the controls of the gui)

..and I wasn't using this method (below) in my example because my script has multiple gui's so i'm already using the advanced parameter of guigetmsg().

So in order to get the text i needed without going too far, an additional element was added to the array which was read in the 'Case Else' loop.

Case $aLoad[1] To $aLoad[$iCount]
    ; Set label to loaded element
    GUICtrlSetData($hLabel_1, GUICtrlRead($iMsg, 1))

Doesn't seem like my typo i found in the menu item creating hasn't made any difference.

So effectively the only solution is to have a seperate function swap the control ids of the dummy's needed? it seems that only updating the menu items is an issue..

Edited by katoNkatoNK

Share this post


Link to post
Share on other sites

katoNkatoNK,

Once again - if you posted your full code rather than trying to describe the symptoms or posting replicators that work I might be able to help more effectively. As it is I have no real idea what you are doing that might cause a problem with the UDF. :huh2:

So a simple bargain: Full code = help; No code = No help. OK? ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Ok, ill do that, did some more testing on the example i posted and it actualy doesn't work .. if you edit the .txt add sections while the gui is open the delete function moves into the load menu(click a load item and it shows the delete message), so ye dummy's would be used to solve this.

Here's my script it's dirty.. 1200 lines of it..

Note: if you're using Win7 it'll run fine, otherwise it might not because of the WMI used..

Edit: Removed full script, see examples..

Edited by katoNkatoNK

Share this post


Link to post
Share on other sites

katoNkatoNK,

Thank you for that - 1200 uncommented lines! But I did ask for it, I suppose. :huh2:

if you edit the .txt add sections while the gui is open

Which ".txt add" sections and which GUI (I count at least 4)? Please understand that no-one else understands how your code works (particularly without any comments) and you have to give some hints as to where you have a problem. And especially when you use such a convoluted way of creating your GUIs - I remember seeing your thread about it and giving it a wide berth! :alien:

Can you please give me some line numbers to define the sections where you do this ".txt add" thing whcih causes the problem. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Sorry for that, i didn't give it much thought :huh2:

I hope my stripping it down to the relevant piece is better than last..

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

#include <GUIConstantsEx.au3>
#include "GUIExtender.au3"

Opt('MustDeclareVars', 1)

Global $cFile = @ScriptDir & "\test.txt"

Global $aSectionNames = IniReadSectionNames($cFile), $iCurrent, $iNew, $iLast
Global $iLoad[1][2] = [[0, 2]], $iDelete[1][2] = [[0, 2]]

Global $hGUI, $iMsg
Global $aData[3][2] = [[9, ""],["Adapter", ""],["Description", ""]]

For $i = 1 To 20    ;make a few sections
    $aData[1][1] = $aData[1][0] & $i
    $aData[2][1] = $aData[2][0] & $i
    IniWriteSection($cFile, "Item" & $i, $aData)
Next

_hMain()

Func _hMain()
    Local $Menu, $Load, $Delete, $View, $IP_Section
    Local $pTitle, $aTitle, $dTitle, $Current, $sLoad, $sDelete
    Local $Static1, $Section1

    $hGUI = GUICreate("LazyIP", 300, 270, -1, -1)
    $Menu = GUICtrlCreateMenu("Menu")
    $Load = GUICtrlCreateMenu("Load", $Menu)
    $Delete = GUICtrlCreateMenu("Delete", $Menu)
    GUICtrlCreateMenuItem("", $Menu)
    $View = GUICtrlCreateMenu("View", $Menu)
    $IP_Section = GUICtrlCreateMenuItem("Section1", $View)

    _GUIExtender_Init($hGUI)

    $Static1 = _GUIExtender_Section_Start(0, 100)
    GUICtrlCreateLabel("Preset:", 22, 14)
    GUICtrlCreateLabel("Adapter:", 15, 32)
    $pTitle = GUICtrlCreateLabel("", 60, 14, 215, 20)
    $aTitle = GUICtrlCreateLabel("", 60, 32, 215, 20)
    $dTitle = GUICtrlCreateLabel("", 60, 50, 215, 18)
    GUICtrlCreateGroup("", 5, 0, 280, 70)
    GUICtrlCreateLabel("Section1", 35, 75)
    _GUIExtender_Section_Action($Static1 + 1, "", "", 10, 75, 15, 15)
    _GUIExtender_Section_End()

    $Section1 = _GUIExtender_Section_Start(100, 150)
    GUICtrlCreateLabel("", 0, 100, 300, 150)
    GUICtrlSetBkColor(-1, 0xFF0000)
    _GUIExtender_Section_End()

    _GUIExtender_Section_Extend(0, False)

    If IsArray($aSectionNames) Then
        _SetMenuItems($iLoad, $iLoad, $aSectionNames, $Load)
        _SetMenuItems($iDelete, $iDelete, $aSectionNames, $Delete)
    EndIf

    GUISetState(@SW_SHOW, $hGUI)

    While 1
        $iMsg = GUIGetMsg(1)

        $Current = GUICtrlRead($pTitle)

        _UpdateMenuItems($iLoad, $iDelete) ;loop update flag

        Switch $iMsg[1]
            Case $hGUI
                Switch $iMsg[0]
                    Case $IP_Section
                        If BitAND(GUICtrlRead($IP_Section), $GUI_CHECKED) = $GUI_CHECKED Then
                            _GUIExtender_Section_Extend($Section1, False)
                            GUICtrlSetState($IP_Section, $GUI_UNCHECKED)
                        Else
                            _GUIExtender_Section_Extend($Section1)
                            GUICtrlSetState($IP_Section, $GUI_CHECKED)
                        EndIf
                    Case $GUI_EVENT_RESTORE
                        WinActivate($hGUI)
                    Case $GUI_EVENT_CLOSE
                        Exit
                    Case Else
                        If $iLoad[0][0] > 0 Then    ;loop for iLoad's item text
                            If $iMsg[0] >= $iLoad[1][0] And $iMsg[0] <= $iLoad[$iLoad[0][0]][0] Then
                                For $A = 1 To $iLoad[0][0]
                                    If $iMsg[0] = $iLoad[$A][0] Then
                                        $sLoad = $iLoad[$A][1]
                                        ExitLoop
                                    EndIf
                                Next
                                _Load($sLoad, $pTitle, $aTitle, $dTitle)
                            EndIf
                        EndIf
                        If $iDelete[0][0] > 0 Then  ;loop for iDelete's item text
                            If $iMsg[0] >= $iDelete[1][0] And $iMsg[0] <= $iDelete[$iDelete[0][0]][0] Then
                                For $A = 1 To $iDelete[0][0]
                                    If $iMsg[0] = $iDelete[$A][0] Then
                                        $sDelete = $iDelete[$A][1]
                                        ExitLoop
                                    EndIf
                                Next
                                _Delete($sDelete, $Current, $pTitle, $aTitle, $dTitle)
                                ;If Not @error Then _UpdateMenuItems($Load, $Delete)
                            EndIf
                        EndIf
                EndSwitch
        EndSwitch

        _GUIExtender_Action($iMsg[0])

        Local $SectionStatus = _GUIExtender_Section_State($Section1)
        If $SectionStatus = 0 Then
            If BitAND(GUICtrlRead($IP_Section), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($IP_Section, $GUI_UNCHECKED)
        ElseIf $SectionStatus = 1 Then
            If BitAND(GUICtrlRead($IP_Section), $GUI_CHECKED) <> $GUI_CHECKED Then GUICtrlSetState($IP_Section, $GUI_CHECKED)
        EndIf
    WEnd
EndFunc   ;==>_hMain

Func _SetMenuItems(ByRef $aDeleteArray, ByRef $aCreateArray, $iArray, $hCtrl)   ;delete | add - menu items function
    If IsArray($aDeleteArray) Then
        For $A = 1 To $aDeleteArray[0][0]
            GUICtrlDelete($aDeleteArray[$A][0])
            $aDeleteArray[$A][0] = -1
        Next
    EndIf
    If IsArray($aCreateArray) And IsArray($iArray) Then
        ReDim $aCreateArray[$iArray[0] + 1][2]
        $aCreateArray[0][0] = $iArray[0]
        Local $iText
        For $A = 1 To $aCreateArray[0][0]
            $iText = $iArray[$A]
            $aCreateArray[$A][0] = GUICtrlCreateMenuItem($iText, $hCtrl)
            $aCreateArray[$A][1] = $iText
        Next
    EndIf
    Return 1
EndFunc   ;==>_SetMenuItems

Func _UpdateMenuItems($hHandle1, $hHandle2) ;loop $iNew and $iCurrent to keep items updated
    If FileExists($cFile) Then
        $iCurrent = IniReadSectionNames($cFile)
        $iNew = ""
        If IsArray($iCurrent) Then
            For $i = 1 To $iCurrent[0]
                $iNew = $iNew & $iCurrent[$i]
            Next
            If $iNew <> $iLast Then
                _SetMenuItems($iLoad, $iLoad, $iCurrent, $hHandle1)
                _SetMenuItems($iDelete, $iDelete, $iCurrent, $hHandle2)
                $iLast = ""
                For $i = 1 To $iCurrent[0]
                    $iLast = $iLast & $iCurrent[$i]
                Next
            Else
                Return
            EndIf
        Else
            $iCurrent = ""
            _SetMenuItems($iLoad, $iLoad, $iCurrent, $hHandle1)
            _SetMenuItems($iDelete, $iDelete, $iCurrent, $hHandle2)
        EndIf
    EndIf
EndFunc   ;==>_UpdateMenuItems

Func _Load($pLoad, $Preset, $Adapter, $Description) ;set the labels with the section data
    If FileExists($cFile) Then
        $aSectionNames = IniReadSectionNames($cFile)
        If IsArray($aSectionNames) Then
            Local $aLoad = IniReadSection($cFile, $pLoad)
            If @error Then Return SetError(3)
            GUICtrlSetData($Preset, $pLoad)
            If $aLoad[1][1] = "n/a" Or $aLoad[2][1] = "n/a" Then
                GUICtrlSetData($Adapter, "n/a")
                GUICtrlSetData($Description, "n/a")
            Else
                GUICtrlSetData($Adapter, $aLoad[1][1])
                GUICtrlSetData($Description, $aLoad[2][1])
            EndIf
        Else
            Return SetError(2)
        EndIf
    Else
        Return SetError(1)
    EndIf
EndFunc   ;==>_Load

Func _Delete($pDel, $pCur, $hPreset, $hAdapter, $hDescription) ;delete from ini and clear controls
    If MsgBox(4, "Delete Preset", "Delete the following preset:" & @CRLF & $pDel) = 6 Then
        If $pDel = $pCur Then
            GUICtrlSetData($hPreset, "")
            GUICtrlSetData($hAdapter, "")
            GUICtrlSetData($hDescription, "")
        EndIf
        IniDelete($cFile, $pDel)
    EndIf
EndFunc   ;==>_Delete

otherwise:

Line 89 : menu items created

Line 185 - 206 : set the menu items on gui startup. (first time)

Line 432 - 475 : loop to get the menu item's text.

Line 660: Function setting the menu items

Line 698: Function that updates the preset name's/menu items

And here is a 'solution' i thought might work, as the menu items are dynamic there's some checks if it need to refill or open more controlID's before creating..

Func _SetMenuItems(ByRef $aDeleteArray, ByRef $aCreateArray, $iArray, $CtrlID)
    If IsArray($aDeleteArray) Then ; Array holding the Control ID's
        For $i = 1 To $iArray[0][0] ;delete previous amount of menu items
            GUICtrlDelete($aDeleteArray[$i][0])
        Next
    EndIf
    If IsArray($iArray) Then        ;Section name array
        If $iArray[0] > $aCreateArray[0][0] Then        ;delete remaining items if there are more
            For $A = $aCreateArray[0][0] To $iArray[0]
                GUICtrlDelete($aCreateArray[$A][0])
            Next
        ElseIf $iArray[0] < $aCreateArray[0][0] Then    ;fill ControlIDs when section names is less than what was deleted
            For $A = $aCreateArray[0][0] To $iArray[0] Step -1
                $aCreateArray[$i][0] = GUICtrlCreateDummy()
            Next
        EndIf
        $aCreateArray[0][0] = $iArray[0]    ;amount to delete on next update
        For $A = 1 To $aCreateArray[0][0]
            $aCreateArray[$A][0] = GUICtrlCreateMenuItem($iArray[$A], $CtrlID)
            $aCreateArray[$A][1] = $iArray[$A]  ;add the menu item's text for later reference
        Next
    Else
        For $i = 1 To $aCreateArray[0][0]   ;fill empty spaces if no section names
            $aCreateArray[$i][0] = GUICtrlCreateDummy()
        Next
        Return
    EndIf
EndFunc

Thank you for you time

KatoNK..

P.s I don't know of a better way to create two gui's that are almost used for the same thing and whatever else was broken in my script ;)

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

katoNkatoNK,

OK, on random occasions I can get the new stripped down example to fail as you described earlier - asking it to load the final item actually asks you if you want to delete it instead. However, I have added a few debug lines and the problem is does not seem to come from my UDF - the menuitems are being created and deleted and the ControlIDs are well outside of the GUIExtender array limits. :huh2:

I will investigate further! :alien:

M23

Edit:

Anther 30 mins of testing and I have a possible solution. Only once in that time did I get the problem and I know why - as I dragged the mouse from the <Load> menuitem to the list of Items, I clipped the <Delete> menuitem and the list changed. It is difficult to spot because the content of the 2 lists is identical, but I noticed that the positioning was not quite right before I pressed - and when I did press I got the "Delete" dialog. ;)

So I am as convinced as I can be that this problem is nothing to do with the UDF. I am going to ask a Mod to move the relevant posts into another thread to prevent cluttering this one. :ph34r:

M23

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

strange.., Thanks for taking a look..

Sorry, i'm struggling to follow amidst trying to make a working example and find a flexible solution.

What of the static labels dissapearing though, i get it every now and then even when just deleting an entry - Is this caused by the menu item being removed or because the deleted item was the current item that was 'loaded'? And can this be fixed with the dummy solution?

KatoNK..

Share this post


Link to post
Share on other sites

katoNkatoNK,

Certainly the labels were blanked if you deleted the currently loaded item - but I never saw any other peculiar behaviour. :huh2:

Let me play with it some more - I am very busy tomorrow, but I will try and find some time in the evening. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Ok great, much appreciated Melba!!

Just so you know exactly what to look for, the issue is not the label that holds the menu item's text, but it's the static label "Adapter" & "Description" that completely dissapear, then after choosing a menu item, or opening a gui section - it gives the Coord error.

P.S. I do remember coming across the error of the dynamic menu items not being in the correct hardcoded menu when i first started with my script ( delete item in loaded ) - and that was fixed by keeping each items handle array seperate from the rest - so i'm not too sure what to make of this.

Edit:

The full config is just deleting static controls now, when i try add/delete items even if not loaded - until it crashes and give the error..

KatoNk.........

Edited by katoNkatoNK

Share this post


Link to post
Share on other sites

katoNkatoNK,

I know what is happening - and how to solve it! ;)

The problem is the tray menu. When you are deleting the tray menu items you are using GUICtrlDelete - you need to use TrayItemDelete for the tray menu items.

Because you use a different function to detect tray menu press (TrayGetMsg as opposed to GUIGetMsg) the tray menu controls are stored in a different array from the GUI controls - these are the ControlIDs I get returned when I run the script:

GUI menu items        - 3 to 22
GUI controls          - 23 to 60
Additional menu items - 63 to 102
Tray menu items       - 18 upwards                 - cannot over write existing controls, so must be in a different array

But when you delete these tray menu items you are using GUICtrlDelete and so deleting the GUI controls with the same values (some menu items and early controls)! :huh2:

So the solution is for you to go through the code and make sure that when you enter your _SetMenuItems function, you use TrayItemDelete to remove the tray menu items. Then you will address the correct array and will not inadvertantly remove GUI controls.

I hope that is clear enough for you to fix the problem. If not ask again. :alien:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Nice find ;) ..i wouldn't be able to tell you why i didn't pick that up . lol

Tested it quite a bit, and it's working!

.. and about a post earlier ~ ".txt add" ( post 8 )

I meant to say, "edit the .txt and add sections" meaning manually :huh2:

The problem with the menu items crossing from Load ~ Delete is still happening - i haven't found it messing with any other menu's though.. (should i place dummy's in all dynamic spaces just to be sure?)

This can be sorted out by creating the dummy's and swapping for menu-items?

I've tried to get a nice function that swaps the items working but an extra item always gets added..

Edit:

I Hope you or someone doesn't mind helping further on this problem..

Here's a possible solution..or at least my idea of what needs to happen.

Updated:

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

#include <GUIConstantsEx.au3>
#include <Array.au3>
#include "GUIExtender.au3"

Global $cFile = @DesktopDir & "\test.txt", $iCurrent, $iNew, $iLast
Global $iLoad[50][2] = [[49, ""]], $iDelete[50][2] = [[49, ""]] ; Array for each menu's control id's - amount of dummy's to start off with
Global $hGUI, $mLoad, $mDelete, $hLabel[3], $hButton, $hExt, $iMsg, $sLoad, $sDelete, $Current

Global $aData[3][2] = [[9, ""],["Key1", "Value1"],["Key2", "Value2"]]
For $i = 1 To 20 ; Make a few sections
    IniWriteSection($cFile, "Section" & $i, $aData)
Next

Global $iSectionNames = IniReadSectionNames($cFile)

$hGUI = GUICreate("Test", 500, 500)

$mLoad = GUICtrlCreateMenu("Load")
_SetDummyItems($iLoad) ; 49
$mDelete = GUICtrlCreateMenu("Delete")
_SetDummyItems($iDelete)

_GUIExtender_Init($hGUI)

_GUIExtender_Section_Start(0, 300)
GUICtrlCreateLabel("Section Name:", 50, 50, 100, 20)
GUICtrlCreateLabel("Key 1:", 50, 100, 100, 20)
GUICtrlCreateLabel("Key 2:", 50, 150, 100, 20)
$hLabel[0] = GUICtrlCreateLabel("Section Name", 200, 50, 100, 20)
$hLabel[1] = GUICtrlCreateLabel("Value 2", 200, 100, 100, 20)
$hLabel[2] = GUICtrlCreateLabel("Value 3", 200, 150, 100, 20)
$hButton = GUICtrlCreateButton("Update Section Names", 50, 200, 150, 50)
_GUIExtender_Section_End()

$hExt = _GUIExtender_Section_Start(300, 200)
GUICtrlCreateLabel("", 0, 300, 500, 200)
GUICtrlSetBkColor(-1, 0xFFF000)
_GUIExtender_Section_End()
_GUIExtender_Section_Action($hExt, "", "", 470, 10, 15, 15) ; Section button

_SetMenuItems($iLoad, $iLoad, $iSectionNames, $mLoad)
_SetMenuItems($iDelete, $iDelete, $iSectionNames, $mDelete)
GUISetState(@SW_SHOW, $hGUI)

While 1
    $iMsg = GUIGetMsg()
    $Current = GUICtrlRead($hLabel[0])
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            _UpdateMenuItems() ; Gives each update a flag to prevent unneccesary deleting of controls
        Case Else
            If $iLoad[0][0] > 0 Then ; Loop for the menu item within the array count
                If $iMsg >= $iLoad[1][0] And $iMsg <= $iLoad[$iLoad[0][0]][0] Then
                    For $A = 1 To $iLoad[0][0]
                        If $iMsg = $iLoad[$A][0] Then
                            $sLoad = $iLoad[$A][1]
                            ExitLoop
                        EndIf
                    Next
                    _Load($sLoad) ; Set each label with the section's values
                EndIf
            EndIf
            If $iDelete[0][0] > 0 Then ; Loop for the menu item within the array count
                If $iMsg >= $iDelete[1][0] And $iMsg <= $iDelete[$iDelete[0][0]][0] Then
                    For $A = 1 To $iDelete[0][0]
                        If $iMsg = $iDelete[$A][0] Then
                            $sDelete = $iDelete[$A][1]
                            ExitLoop
                        EndIf
                    Next ; Delete selected section - if it is loaded then clear controls
                    If MsgBox(4, "Delete Preset", "Delete the following preset:" & @CRLF & $sDelete) = 6 Then
                        If $sDelete = $Current Then
                            For $i = 0 To 2
                                GUICtrlSetData($hLabel[$i], "")
                            Next
                        EndIf
                        IniDelete($cFile, $sDelete)
                    EndIf
                EndIf
            EndIf
    EndSwitch
    _GUIExtender_Action($iMsg)
WEnd

Func _SetDummyItems(ByRef $aDummyArray, $iCount = "") ; Hardcode the average amount of dummy's needed
    If IsInt($iCount) Then $aDummyArray[0][0] = $iCount
    For $i = 1 To $aDummyArray[0][0]
        $aDummyArray[$i][0] = GUICtrlCreateDummy()
    Next
    $aDummyArray[0][0] = 0 ; No need to delete any dummy's when entering the function to create the menu items
    Return 1
EndFunc

Func _SetMenuItems(ByRef $aDeleteArray, ByRef $aCreateArray, $iArray = -1, $iCtrl = 0)
    If IsArray($aDeleteArray) Then ; Array holding the Control ID's - initial dummy array
        For $i = 1 To $aDeleteArray[0][0]
            GUICtrlDelete($aDeleteArray[$i][0]) ; delete previous amount of menu items created
        Next
    EndIf
    If IsArray($iArray) Then ; Item array
        If IsArray($aCreateArray) Then ; Array holding the Control ID's ( initial dummy array )
            If $iArray[0] > $aCreateArray[0][0] Then ; Delete remaining items if there are more
                If $aCreateArray[0][0] = 0 Then $aCreateArray[0][0] += 1
                For $A = $aCreateArray[0][0] To $iArray[0]
                    GUICtrlDelete($aDeleteArray[$A][0])
                Next
            ElseIf $iArray[0] < $aCreateArray[0][0] Then ; Fill ControlIDs if section names is less than what was deleted
                For $A = $iArray[0] + 1 To $aCreateArray[0][0] ; Add 1 to stop it from making a dummy in the last place holder of $iArray[0]
                    $aCreateArray[$i][0] = GUICtrlCreateDummy()
                Next
            EndIf
            For $A = 1 To $iArray[0] ; now make the items
                $aCreateArray[$A][0] = GUICtrlCreateMenuItem($iArray[$A], $iCtrl)
                $aCreateArray[$A][1] = $iArray[$A] ;add the menu item's text for later reference
            Next
        EndIf
    Else
        For $i = 1 To $aCreateArray[0][0] ; Refill empty spaces if there were no items
            $aCreateArray[$i][0] = GUICtrlCreateDummy()
        Next
        $aCreateArray[0][0] = $iArray[0]
        Return
    EndIf
    $aCreateArray[0][0] = $iArray[0] ; Amount to delete on next update ( stabilise loop )
EndFunc

Func _UpdateMenuItems()
    If FileExists($cFile) Then ; check for any changes in the ini content to update items
        $iSectionNames = IniReadSectionNames($cFile)
        $iNew = ""
        For $i = 1 To $iSectionNames[0]
            $iNew &= $iNew & $iSectionNames[$i]
        Next
        If $iNew <> $iLast Then
            _SetMenuItems($iLoad, $iLoad, $iSectionNames, $mLoad)
            _SetMenuItems($iDelete, $iDelete, $iSectionNames, $mDelete)
        EndIf
        $iLast = ""
        For $i = 1 To $iSectionNames[0]
            $iLast &= $iLast & $iSectionNames[$i]
        Next
    EndIf
EndFunc   ;==>_UpdateMenuItems

Func _Load($iLoad)
    If FileExists($cFile) Then
        $iSectionNames = IniReadSectionNames($cFile) ; Update & recheck item exists
        If IsArray($iSectionNames) Then
            Local $aLoad = IniReadSection($cFile, $iLoad)
            If @error Then
                MsgBox(0, "", "No Section")
                Return
            EndIf
            GUICtrlSetData($hLabel[0], $iLoad)
            GUICtrlSetData($hLabel[1], $iLoad & " - " & $aLoad[1][1])
            GUICtrlSetData($hLabel[2], $iLoad & " - " & $aLoad[2][1])
        Else
            MsgBox(0, "", "Update Menu Items")
        EndIf
    Else
        MsgBox(0, "", "No File")
    EndIf
EndFunc   ;==>_Load

katonk..

Edited by katoNkatoNK

Share this post


Link to post
Share on other sites

katoNkatoNK,

Glad I could get to the bottom of it! :alien:

Please do not take this personally, but I believe that many of your problems stem from the fact that your code often uses single functions to do many things and these functions are often extremely complex. I suggest that you rewrite the code to use functions with a single function (pun fully intended!) - it is much easier to debug code that way. For instance you would probably have not made the GUICtrlDelete/TrayItemDelete error if the functions had been separate. :huh2:

And do not worry that this will grossly inflate your scripts:

- 1. By using the #Region/#Endregion directives in SciTE you can fold your script to fit nicely into the GUI while you are coding - I am currently working on a 4454-line script which is folded into a mere 16 lines, and I can reach any section of it with just a few clicks.

- 2. The percentage of a compiled AutoIt .exe taken by the actual script is relatively small - so who cares about a few more lines! ;)

You can look into combining your functions into multiple-use versions once they work satisfactorily on their own.

Good luck. :ph34r:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thanks for all the help Melba!

Whatever caused the menu swapping between the UDF and dynamic arrays, i still don't know..

..and ye i have been concentrating on the small bits first but something simple always slips by :)

I've updated the solution (last example of mine) that is working for me, using dummy controls with dynamic items from an ini.

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  
Followers 0