Sign in to follow this  
Followers 0
OmYcroN

While and GuiGetMsg()

5 posts in this topic

Hi. I have a problem whit those two.

While True
    $gMsg = GUIGetMsg()
    
    If $gMsg == $GUI_EVENT_CLOSE Then
        Exit
    Else
        For $i = 0 To $categoriesSize - 1
            If $gMsg == $aCategories[$i] Then
                If $aCategoriesStatus[$i] == 0 Then
                    selectAllFromCategory($hGMainTree, $categories[$i], $aNameSoftwares[$i], 0)
                    $aCategoriesStatus[$i] = 1
                ElseIf $aCategoriesStatus[$i] == 1 Then
                    selectAllFromCategory($hGMainTree, $categories[$i], $aNameSoftwares[$i], 1)
                    $aCategoriesStatus[$i] = 0
                EndIf               
            EndIf
        Next
    EndIf   
WEnd

The thing is that when i click something the selectAllFromCategory function is executed forever and not once. Why ?

Share this post


Link to post
Share on other sites



Maybe you can to add whole script, or just demo with that funcions... never mind, it will be forever because $aCategoriesStatus[$i] stay always 0, maybe you need to add $aCategoriesStatus[$i] = 2, and it will not be forever calling funcion... But, you are doing whole thing wrong...

You just can to do that like this, for example:

(if I understand you correctly what you want)

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $Button1[10]

$Form1 = GUICreate("Form1", 633, 447, 193, 125)
For $a = 1 To 5
$Button1[$a] = GUICtrlCreateButton("Button1", 8, 8 *($a*5), 75, 25, 0)
Next
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1[1] To $Button1[5]
            MsgBox(0,"Call funcion",$nMsg)
    EndSwitch
WEnd

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Share this post


Link to post
Share on other sites

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1[1] To $Button1[5]
            MsgBox(0,"Call funcion",$nMsg)
    EndSwitch
WEnd

Case $Button1[1] To $Button1[5] => That s new to me and looks very nice but if i use that how can i know at what index of $Button1 am i ?

Share this post


Link to post
Share on other sites

Well, it's easy, for example:

Case $Button1[1] To $Button1[5]
If $nMsg = $Button1[1] Then
MsgBox(0,"Call funcion","Clicked First button")
endif

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Share this post


Link to post
Share on other sites

This is the code :

#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <TreeviewConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <GuiTreeView.au3>

#include "globals.au3"
#include "functions.au3"

; Create gui
$g = GUICreate($gTitle, $gWidth, $gHeight)

; Create main tree
$gMainTree = GUICtrlCreateTreeView(5, 5, $gMainTreeWidth, $gMainTreeHeight, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_CHECKBOXES), $WS_EX_CLIENTEDGE)

; Array that contains folder's names
$categories = getFileNames(getFileNumber())
; Number of folders found
$categoriesSize = UBound($categories)

; Array that contains items id-s
Dim $aCategories[$categoriesSize]
; Array that contains items status (1 ==> checked / 0==> unckecked)
Dim $aCategoriesStatus[$categoriesSize]
; Array that contains subitems number
Dim $aSoftwaresSize[$categoriesSize]
; Array that contains 'sub'items id-s
Dim $aSoftwaresIDs[$categoriesSize]

; For each folder found
For $i = 0 To $categoriesSize - 1
; Assign id's for each item created
    $aCategories[$i] = GUICtrlCreateTreeViewItem($categories[$i], $gMainTree)
; Set the status of the controls to uncheched
    $aCategoriesStatus[$i] = 0
; Read the subfolders from each folder found and put the into an array
    $aSoftwares = getFileNames(getFileNumber($categories[$i]), $categories[$i])
; Assign number of subfolders found in each folder
    $aSoftwaresSize[$i] = UBound($aSoftwares)
    
; Create a temporary array for each folder
    Dim $tempASoftwares[$aSoftwaresSize[$i]]
    
; For each subfolder found
    For $j = 0 To $aSoftwaresSize[$i] - 1
    ; Assign id's for each subitem created
        $tempASoftwares[$j] = GUICtrlCreateTreeViewItem($aSoftwares[$j], $aCategories[$i])
    Next
; Assign the 'sub'control's id's to each control created
    $aSoftwaresIDs[$i] = $tempASoftwares
Next

_ArrayDisplay($categories)
MsgBox(0, "", $aSoftwaresSize[0])
_ArrayDisplay($aSoftwaresIDs[0])

GUISetState()
    
;while loop 
While True
    $gMsg = GUIGetMsg()
    
    Switch $gMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

And some picture to understand better what i want ...

post-33427-1227654546_thumb.png

My question is : How can i write a function that selects all the subitem of an item ?

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