Sign in to follow this  
Followers 0
Bob Wya

Help with Child window (pane in main window)

6 posts in this topic

#1 ·  Posted (edited)

Hi all,

I have a backup program for storing files on DVDs. There is a left pane with a list of DVD numbers (just a simple control).

Anyway the problem I had was that the right pane shows a TreeView of the folders and files to be backed up. For a big project this

right pane cannot be a simple control (a big TreeView of files and folders easily goes over 4096 controls). So I define a single GUI for each

DVD i.e. backup to 25 DVDs => 25 GUI handles (with a single TreeView control and lots of file and folder items).

The problem is that when tracing the function GUICreate function errors at about 26 GUI's. So what gives I thought (in theory) I could have

1000 GUI handles each with 4096 controls right??!! All but 1 of the stacked (on top each other) TreeView GUI's is hidden at any one time.

The only GUI child window I have for the main window in the test run is a Status bar... So that makes only 27 GUI handles!!

Do the controls of the right pane GUIs count towards the 4096 controls allocated the main GUI because they are defined as child windows or something??

Rapidly losing my mind...

Bob Wya

CODE
Func Create_New_Disc_Window($disc)

Local $max_disc= UBound($global_disc_gui_array, 1)

Local $i_disc

Local $handle

Local $control

Local $disc_text

If Not IsArray($global_disc_gui_array) Then

Dim $global_disc_gui_array[$disc][$en_disc_gui_max]

Else

ReDim $global_disc_gui_array[$disc][$en_disc_gui_max]

EndIf

For $i_disc= $max_disc+1 To $disc

$global_disc_gui_array[$i_disc-1][$en_disc_gui_flag] = $en_backedup_flag

$disc_text = StringFormat("%0" & $const_max_disc_digits & "d", $i_disc)

$handle = GUICreate($disc_text, $global_active_project_width, $global_active_project_height, $global_active_project_x, $global_active_project_y, BitOR($DS_MODALFRAME, $WS_CHILD), $WS_EX_DLGMODALFRAME, $main_window_handle)

ConsoleWrite('>Error code: ' & @error & @crlf & @crlf & '@@ Trace(662) : $handle = GUICreate($disc_text, $global_active_project_width, $global_active_project_height, $global_active_project_x, $global_active_project_y, BitOR($DS_MODALFRAME, $WS_CHILD), $WS_EX_DLGMODALFRAME, $main_window_handle)' & @crlf) ;### Trace Console

;If (@error = 1) Then Error($error_gui_handle,"GUICreate("""", $global_active_project_width, $global_active_project_height, $global_active_project_x, $global_active_project_y, BitOR($DS_MODALFRAME, $WS_CHILD), $WS_EX_DLGMODALFRAME, $main_window_handle) )")

GUISetState(@SW_HIDE, $handle)

GUISwitch($handle)

$global_disc_gui_array[$i_disc-1][$en_disc_gui_handle] = $handle

$control = GUICtrlCreateTreeView(0, 0, $global_active_project_width, $global_active_project_height, BitOR($TVS_HASBUTTONS,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_SHOWSELALWAYS,$TVS_TRACKSELECT ) )

If ($control = 0) Then Error($error_gui_control,"GUICtrlCreateTreeView(0, 0, $global_active_project_width, $global_active_project_height, BitOR($TVS_HASBUTTONS,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_SHOWSELALWAYS,$TVS_TRACKSELECT ) )")

$global_disc_gui_array[$i_disc-1][$en_disc_gui_tree_control] = $control

GUISwitch($main_window_handle)

$global_disc_gui_array[$i_disc-1][$en_disc_gui_list_control] = GUICtrlCreateListViewItem($disc_text, $control_discs)

GUICtrlSetColor($global_disc_gui_array[$i_disc-1][$en_disc_gui_list_control], $colour_folder_backedup)

GUICtrlSetOnEvent(-1, "Handle_Disc_Control")

$global_disc_gui_array[$i_disc-1][$en_disc_gui_flag] = 0x0000

Next

$max_disc=$disc

For $i_disc= 1 To $max_disc-1

GuiCtrlSetState($global_disc_gui_array[$i_disc-1][$en_disc_gui_list_control], $GUI_NOFOCUS)

Next

GuiCtrlSetState($global_disc_gui_array[$disc-1][$en_disc_gui_list_control], $GUI_FOCUS)

EndFunc

Edited by Bob Wya

Share this post


Link to post
Share on other sites



Hi all,

I have a backup program for storing files on DVDs. There is a left pane with a list of DVD numbers (just a simple control).

Anyway the problem I had was that the right pane shows a TreeView of the folders and files to be backed up. For a big project this

right pane cannot be a simple control (a big TreeView of files and folders easily goes over 4096 controls). So I define a single GUI for each

DVD i.e. backup to 25 DVDs => 25 GUI handles (with a single TreeView control and lots of file and folder items).

The problem is that when tracing the function GUICreate function errors at about 26 GUI's. So what gives I thought (in theory) I could have

1000 GUI handles each with 4096 controls right??!! All but 1 of the stacked (on top each other) TreeView GUI's is hidden at any one time.

The only GUI child window I have for the main window in the test run is a Status bar... So that makes only 27 GUI handles!!

Do the controls of the right pane GUIs count towards the 4096 controls allocated the main GUI because they are defined as child windows or something??

Rapidly losing my mind...

Bob Wya

CODE
Func Create_New_Disc_Window($disc)

Local $max_disc= UBound($global_disc_gui_array, 1)

Local $i_disc

Local $handle

Local $control

Local $disc_text

If Not IsArray($global_disc_gui_array) Then

Dim $global_disc_gui_array[$disc][$en_disc_gui_max]

Else

ReDim $global_disc_gui_array[$disc][$en_disc_gui_max]

EndIf

For $i_disc= $max_disc+1 To $disc

$global_disc_gui_array[$i_disc-1][$en_disc_gui_flag] = $en_backedup_flag

$disc_text = StringFormat("%0" & $const_max_disc_digits & "d", $i_disc)

$handle = GUICreate($disc_text, $global_active_project_width, $global_active_project_height, $global_active_project_x, $global_active_project_y, BitOR($DS_MODALFRAME, $WS_CHILD), $WS_EX_DLGMODALFRAME, $main_window_handle)

ConsoleWrite('>Error code: ' & @error & @crlf & @crlf & '@@ Trace(662) : $handle = GUICreate($disc_text, $global_active_project_width, $global_active_project_height, $global_active_project_x, $global_active_project_y, BitOR($DS_MODALFRAME, $WS_CHILD), $WS_EX_DLGMODALFRAME, $main_window_handle)' & @crlf) ;### Trace Console

;If (@error = 1) Then Error($error_gui_handle,"GUICreate("""", $global_active_project_width, $global_active_project_height, $global_active_project_x, $global_active_project_y, BitOR($DS_MODALFRAME, $WS_CHILD), $WS_EX_DLGMODALFRAME, $main_window_handle) )")

GUISetState(@SW_HIDE, $handle)

GUISwitch($handle)

$global_disc_gui_array[$i_disc-1][$en_disc_gui_handle] = $handle

$control = GUICtrlCreateTreeView(0, 0, $global_active_project_width, $global_active_project_height, BitOR($TVS_HASBUTTONS,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_SHOWSELALWAYS,$TVS_TRACKSELECT ) )

If ($control = 0) Then Error($error_gui_control,"GUICtrlCreateTreeView(0, 0, $global_active_project_width, $global_active_project_height, BitOR($TVS_HASBUTTONS,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_SHOWSELALWAYS,$TVS_TRACKSELECT ) )")

$global_disc_gui_array[$i_disc-1][$en_disc_gui_tree_control] = $control

GUISwitch($main_window_handle)

$global_disc_gui_array[$i_disc-1][$en_disc_gui_list_control] = GUICtrlCreateListViewItem($disc_text, $control_discs)

GUICtrlSetColor($global_disc_gui_array[$i_disc-1][$en_disc_gui_list_control], $colour_folder_backedup)

GUICtrlSetOnEvent(-1, "Handle_Disc_Control")

$global_disc_gui_array[$i_disc-1][$en_disc_gui_flag] = 0x0000

Next

$max_disc=$disc

For $i_disc= 1 To $max_disc-1

GuiCtrlSetState($global_disc_gui_array[$i_disc-1][$en_disc_gui_list_control], $GUI_NOFOCUS)

Next

GuiCtrlSetState($global_disc_gui_array[$disc-1][$en_disc_gui_list_control], $GUI_FOCUS)

EndFunc

I would expect that the 4096 limit is the total number of guicontrols for a script. So if you have 10 gui windows each with 400 guictrls then that is 4000 and you are nearly at the limit.

Maybe you could read the information into arrays and then fill the treeview with the relevant info for a disc when it has to be viewed?


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

I would expect that the 4096 limit is the total number of guicontrols for a script. So if you have 10 gui windows each with 400 guictrls then that is 4000 and you are nearly at the limit.

Maybe you could read the information into arrays and then fill the treeview with the relevant info for a disc when it has to be viewed?

OK that is really important for me to know!! Could someone in the know please clear this up!! Can each GUI handle have <~4000 controls each??

The whole structure is stored in a massive 2-dimensional array so I guess I can construct the controls on the fly but it would be a pain in the ass to change everything (yet again :-) )

I'll keep on debugging to try and work out what is going on....

Bob Wya

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

OK that is really important for me to know!! Could someone in the know please clear this up!! Can each GUI handle have <~4000 controls each??

The whole structure is stored in a massive 2-dimensional array so I guess I can construct the controls on the fly but it would be a pain in the ass to change everything (yet again :-) )

I'll keep on debugging to try and work out what is going on....

Bob Wya

I am wrong - reading the help file it says max 4096 per window.

I tried this

$n = 0
For $gg = 1 To 1000
       GUICreate("")
    For $cc = 1 To 4095
        
        GUICtrlCreateButton("",10,10,10,10)
        $n += 1
    Next
    ConsoleWrite('n = ' & $n & @CRLF)
Next

As I write this the script is running and is up to over 800,000 buttons!

So I think it's something else. (Memory?)

Edit: Not so clever. Don't try this at home! Scite hung and then I couldn't stop the script with Ctr Alt Del so I had to reset my PC.

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Yeh I think there is a problem with my use of GuiSwitch (??) or something like that.

If I disable the (right-click) context menu for the files in the TreeView Gui all is well

again. Even if I don't access the handler wierd things were happening. Like Firefox

would refresh web tabs to a blank screen, right-click stopped working on all the other

the other windows I was running... Also this GUI programming is wierd shit with all the

aysncronous events I have to start thinking about critical sections and (virtual) parallel

programming... Its giving me a headache!!

Anyway I think the script is working with the context menus disabled (they were useless

eye candy really anyway :-)

Thanks,

Bob Wya

Share this post


Link to post
Share on other sites

This is the offending code...

The whole thing is bit complex as the main data structure is a 2-dimensional array which stores the path on

the DVD of each TreeView entry (prepended with the DVD number). So basically each entry represents

one element of a file path (as in the Windows folder view but this includes files as well).

The array also has controls for each TreeView item and room for a context menu and handle for a properties

popup window. Of course there might be some obscure bugs in my carefully crafted 2-dimensional array

handling routines - but I don't think so!!

Enabling the context menu (but not triggering it) seems to cause problems for big projects

>25 DVDs but not for small ones. It seemed to cause a GUICreate function elsewhere to report an error.

I am sure the GuiSwitch() call at the top (bold) should ensure the file properties control is a subcontrol of the right

TreeView folder/file GUI. The currently commented out code below actually creates the context menu...

What is wierd is how these bugs in my code could bugger up other windows so much!! The code seems to work fine with the

commented out code (or for smaller projects)... Very strange!!

Bob Wya

CODE
Func Process_Backup_File_Path($path, $file_size, $modified_time, $create_time, $flag=0x0000)

Local $isfile = False, $backedup

Local $base_element, $index_element=0

Local $path_element, $subpath, $root_path

Local $new_value[$en_disc_path_element_max]

Local $parent_control

Local $prev_folder_seperator, $folder_seperator=$const_max_disc_digits

Local $context_menu

Local $occurance=0

$disc = Number(StringLeft($path, $const_max_disc_digits))

If UBound($global_disc_gui_array) < $disc Then Create_New_Disc_Window($disc)

GUISwitch($global_disc_gui_array[$disc-1][$en_disc_gui_handle])

$parent_control = $global_disc_gui_array[$disc-1][$en_disc_gui_tree_control]

$root_path = StringRegExpReplace($path, "(\A\d{" & $const_max_disc_digits & "})([a-zA-Z]\:\\|\\\\.*?\\)(.*\z)", "\2", 1)

$path = StringRegExpReplace($path, "(\A\d{" & $const_max_disc_digits & "})([a-zA-Z]\:\\|\\\\.*?\\)(.*\z)", "\1\3", 1)

$backedup = BitAND($en_backedup_flag, $flag)

While Not $isfile

$base_element = $index_element

$occurance += 1

$prev_folder_seperator = $folder_seperator

$folder_seperator = StringInStr($path, "\", 0, $occurance)

If ($folder_seperator < 1) Then

$folder_seperator = StringLen($path)

$isfile = True

EndIf

$subpath= StringLeft($path, $folder_seperator)

$index_element = _ArrayBinarySearch($global_master_path_array, $subpath, $base_element, 0, 2, $en_disc_path_element_path)

If (@error = 0) Then

$parent_control = $global_master_path_array[$index_element][$en_disc_path_element_tree_control]

If Not $backedup Then

$global_disc_gui_array[$disc-1][$en_disc_gui_flag] = BitAND($global_disc_gui_array[$disc-1][$en_disc_gui_flag], BitNOT($en_backedup_flag))

GUICtrlSetColor($global_disc_gui_array[$disc-1][$en_disc_gui_list_control], $colour_folder)

$global_master_path_array[$index_element][$en_disc_path_element_control_flag] = BitAnd($global_master_path_array[$index_element][$en_disc_path_element_control_flag], BitNot($en_backedup_flag))

GUICtrlSetColor($global_master_path_array[$index_element][$en_disc_path_element_tree_control], $colour_folder)

EndIf

ContinueLoop

EndIf

$path_element = StringTrimLeft($subpath, $prev_folder_seperator)

If Not $isfile Then $path_element= StringTrimRight($path_element, 1)

$new_value[$en_disc_path_element_path] = $subpath

$new_value[$en_disc_path_element_root_path] = $root_path

$new_value[$en_disc_path_element_file_size] = $file_size

$new_value[$en_disc_path_element_modified_time] = $modified_time

$new_value[$en_disc_path_element_create_time] = $create_time

$new_value[$en_disc_path_element_control_flag] = $flag

$new_value[$en_disc_path_element_tree_control] = GUICtrlCreateTreeViewItem ($path_element, $parent_control)

If ($new_value[$en_disc_path_element_tree_control] = 0) Then Error($error_gui_control,"GUICtrlCreateTreeViewItem ($path_element, $parent_control)")

; If $isfile Then

; $context_menu = GUICtrlCreateContextMenu ($new_value[$en_disc_path_element_tree_control])

; $new_value[$en_disc_path_element_context_menu_properties_control] = GUICtrlCreateMenuitem ("&Properties", $context_menu)

; GUICtrlSetOnEvent(-1, "Handle_File_Properties")

; Else

$context_menu = 0

$new_value[$en_disc_path_element_context_menu_properties_control] = 0

; EndIf

$new_value[$en_disc_path_element_context_menu_control] = $context_menu

If $backedup Then

$new_value[$en_disc_path_element_control_flag] = BitOr($new_value[$en_disc_path_element_control_flag], $en_backedup_flag)

If $isfile Then

GUICtrlSetColor($new_value[$en_disc_path_element_tree_control], $colour_file_backedup)

Else

GUICtrlSetColor($new_value[$en_disc_path_element_tree_control], $colour_folder_backedup)

EndIf

Else

$new_value[$en_disc_path_element_control_flag] = BitAnd($new_value[$en_disc_path_element_control_flag], BitNot($en_backedup_flag))

If $isfile Then

GUICtrlSetColor($new_value[$en_disc_path_element_tree_control], $colour_file)

Else

GUICtrlSetColor($new_value[$en_disc_path_element_tree_control], $colour_folder)

EndIf

EndIf

$new_value[$en_disc_path_element_properties_window_handle] = 0

$new_value[$en_disc_path_element_properties_window_control_OK] = 0

_ArrayInsert($global_master_path_array, $index_element, $new_value, 2)

$parent_control = $new_value[$en_disc_path_element_tree_control]

WEnd

GUISwitch($main_window_handle)

EndFunc

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