Sign in to follow this  
Followers 0
Syed23

Help on Managing Multiple GUI

8 posts in this topic

Hi All,

i have created 1 parent GUI and one child and another Child for that Child GUI. i am trying to get the control of frst child GUI when i delete the second child GUI but i am unable to do. For your reference i have my example code below. Please give me the suggestions.

Note: Therewere no issue occured.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include"File.au3"
#include "Model.au3"
#include <GuiEdit.au3>
Opt('MustDeclareVars', 1)
Global $Title = " Machine Reporter"
Global $ListView, $GUI, $msg, $Label1, $ComboList, $DestStatus, $Show, $Exit, $GUIshow, $Administrator, $Copy, $Fopen, $numberOfChannels, $MA, $Platform, $OS, $Space
Global $Label,$Label2,$Label3,$Input,$Input2,$Input3,$GUI1,$Label4,$Input4,$OK,$hMenu,$Add,$msgbox
Call("Client")
Func Client()
 $GUI = GUICreate($Title, 580, 600, -1, -1) ; trying the make the GUI to appear on the center of the monitor
 GUISetBkColor(0x00E0FFFF)
 $Show = GUICtrlCreateButton("Show", 460, 240, 90, 60)
 $Administrator = GUICtrlCreateButton("Administrator", 460, 70, 90, 60)
 $Exit = GUICtrlCreateButton("Exit", 460, 460, 90, 60)
 $ListView = GUICtrlCreateListView("S.NO|MAchine Account|Pl|OS|Space Allocated", 5, 10, 430, 580)
 _GUICtrlListView_SetColumnWidth($ListView, 0, 50)
 _GUICtrlListView_SetColumnWidth($ListView, 1, $LVSCW_AUTOSIZE_USEHEADER)
 _GUICtrlListView_SetColumnWidth($ListView, 2, $LVSCW_AUTOSIZE_USEHEADER)
 _GUICtrlListView_SetColumnWidth($ListView, 3, $LVSCW_AUTOSIZE_USEHEADER)
 _GUICtrlListView_SetColumnWidth($ListView, 4, $LVSCW_AUTOSIZE_USEHEADER)
 GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
 $GUIshow = GUISetState()
 Do
  $msg = GUIGetMsg()
  If $msg = $Show Then
   MsgBox(0,"SHOW","SUCCESS")
  EndIf
  If $msg = $Administrator Then
   Call("admin")
  EndIf
  If $msg = $Exit Or $msg = $GUI_EVENT_CLOSE Then
   Exit
  EndIf
 Until $msg = $GUI_EVENT_CLOSE
EndFunc   ;==>Client
 
Func admin()
 GUIDelete($GUI)
 $GUI = GUICreate($Title & "- Administrator", 580, 600, -1, -1) ; trying the make the GUI to appear on the center of the monitor
 GUISetBkColor(0x00E0FFFF)
 $Show = GUICtrlCreateButton("Update", 460, 240, 90, 60)
 $Exit = GUICtrlCreateButton("Exit", 460, 460, 90, 60)
 $ListView = GUICtrlCreateListView("S.NO|MAchine Account|Pl|OS|Space Allocated", 5, 10, 450, 580)
 _GUICtrlListView_SetColumnWidth($ListView, 0, 50)
 _GUICtrlListView_SetColumnWidth($ListView, 1, $LVSCW_AUTOSIZE_USEHEADER)
 _GUICtrlListView_SetColumnWidth($ListView, 2, $LVSCW_AUTOSIZE_USEHEADER)
 _GUICtrlListView_SetColumnWidth($ListView, 3, $LVSCW_AUTOSIZE_USEHEADER)
 _GUICtrlListView_SetColumnWidth($ListView, 4, $LVSCW_AUTOSIZE_USEHEADER)
 GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
  $GUIshow = GUISetState()

 While 1
  Switch GUIGetMsg()
   Case $GUI_EVENT_CLOSE, $Exit
    GUIDelete($GUI)
    Call($GUI)
   Case $Show
    Call("update")
  EndSwitch
 WEnd
EndFunc   ;==>admin
Func update()
$GUI1 = GUICreate($Title&"-Updater",580,300,-1,-1)
$Label = GUICtrlCreateLabel("Machine Account",5,5,110,30)
$Input = GUICtrlCreateInput("",130,5,230,30)
$Label2 = GUICtrlCreateLabel("Pl",5,70,110,30)
$Input2 = GUICtrlCreateInput("",130,70,230,30)
$Label3 = GUICtrlCreateLabel("OS",5,135,110,30)
$Input3= GUICtrlCreateInput("",130,135,230,30)
$Label4 = GUICtrlCreateLabel("Space Allocated",5,200,110,30)
$Input4= GUICtrlCreateInput("",130,200,230,30)
$OK = GUICtrlCreateButton("&OK",420,150,60,60)
GUISetFont(12,400)
GUISetState()
While 1
  Switch GUIGetMsg()
   Case $OK
    If GUICtrlRead($Input)="" Or GUICtrlRead($Input2)="" Or GUICtrlRead($Input3)="" Or GUICtrlRead($Input4)="" Then
     MsgBox(48,$Title&"-Warning","Please fill the all required fields")
    Else
     Call("adminupdate")
    EndIf
   Case $GUI_EVENT_CLOSE
    Exit
  EndSwitch
 WEnd
EndFunc   ;==>admin

Func adminupdate()
 $Add = _GUICtrlListView_GetItemCount($ListView)
 GUICtrlCreateListViewItem($Add+1 & "|" &GUICtrlRead($Input) & "|" & GUICtrlRead($Input2) & "|" & GUICtrlRead($Input3) & "|" & GUICtrlRead($Input4), $ListView)
 $msgbox = MsgBox(68,$Title&"-updater","Do you want to add more?")
 If $msgbox = 6 Then
  Call("clear")
 Else
  GUIDelete($GUI1)
  WinActivate("", "")
  GUICtrlSetState($Show,$GUI_ENABLE)
  GUICtrlSetState($Exit,$GUI_ENABLE)
 EndIf
EndFunc
Func clear()
GUICtrlSetData($Input,"")
GUICtrlSetData($Input2,"")
GUICtrlSetData($Input3,"")
GUICtrlSetData($Input4,"")
EndFunc

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Share this post


Link to post
Share on other sites



Syed23,

Someone needs to read the Managing Multiple GUIs tutorial in the Wiki. ;)

This should work as you want:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include"File.au3"
;#include "Model.au3"
#include <GuiEdit.au3>

Opt('MustDeclareVars', 1)

Global $Title = " Machine Reporter"
Global $ListView, $GUI, $msg, $Label1, $ComboList, $DestStatus, $Show, $Exit, $GUIshow, $Administrator, $Copy, $Fopen, $numberOfChannels, $MA, $Platform, $OS, $Space
Global $Label, $Label2, $Label3, $Input, $Input2, $Input3, $GUI1, $Label4, $Input4, $OK, $hMenu, $Add, $msgbox

Client() ; No need to use Call <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Func Client()
    $GUI = GUICreate($Title, 580, 600, -1, -1) ; trying the make the GUI to appear on the center of the monitor
    GUISetBkColor(0x00E0FFFF)

    $Show = GUICtrlCreateButton("Show", 460, 240, 90, 60)
    $Administrator = GUICtrlCreateButton("Administrator", 460, 70, 90, 60)
    $Exit = GUICtrlCreateButton("Exit", 460, 460, 90, 60)
    $ListView = GUICtrlCreateListView("S.NO|MAchine Account|Pl|OS|Space Allocated", 5, 10, 430, 580)
    _GUICtrlListView_SetColumnWidth($ListView, 0, 50)
    _GUICtrlListView_SetColumnWidth($ListView, 1, $LVSCW_AUTOSIZE_USEHEADER)
    _GUICtrlListView_SetColumnWidth($ListView, 2, $LVSCW_AUTOSIZE_USEHEADER)
    _GUICtrlListView_SetColumnWidth($ListView, 3, $LVSCW_AUTOSIZE_USEHEADER)
    _GUICtrlListView_SetColumnWidth($ListView, 4, $LVSCW_AUTOSIZE_USEHEADER)
    GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)

    GUISetState()

    Do
        $msg = GUIGetMsg()
        Switch $msg ; In most cases Switch is better then lots of If...EndIf
            Case $Show
                Switch GUICtrlRead($Show)
                    Case "Show"
                        MsgBox(0, "SHOW", "SUCCESS")
                    Case "Update"
                        update()
                EndSwitch
            Case $Administrator
                admin() ; No need to use Call <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            Case $Exit, $GUI_EVENT_CLOSE
                Exit
        EndSwitch
    Until $msg = $GUI_EVENT_CLOSE
EndFunc   ;==>Client

Func admin()

    GUICtrlSetState($Administrator, $GUI_HIDE)
    GUICtrlSetData($Show, "Update")

EndFunc   ;==>admin

Func update()

    Local $amsg

    $GUI1 = GUICreate($Title & "-Updater", 580, 300, -1, -1)
    $Label = GUICtrlCreateLabel("Machine Account", 5, 5, 110, 30)
    $Input = GUICtrlCreateInput("", 130, 5, 230, 30)
    $Label2 = GUICtrlCreateLabel("Pl", 5, 70, 110, 30)
    $Input2 = GUICtrlCreateInput("", 130, 70, 230, 30)
    $Label3 = GUICtrlCreateLabel("OS", 5, 135, 110, 30)
    $Input3 = GUICtrlCreateInput("", 130, 135, 230, 30)
    $Label4 = GUICtrlCreateLabel("Space Allocated", 5, 200, 110, 30)
    $Input4 = GUICtrlCreateInput("", 130, 200, 230, 30)
    $OK = GUICtrlCreateButton("&OK", 420, 150, 60, 60)
    GUISetFont(12, 400)
    GUISetState()
    While 1
        $amsg = GUIGetMsg(1)
        Switch $amsg[1]
            Case $GUI1
                Switch $amsg[0]
                    Case $OK
                        If GUICtrlRead($Input) = "" Or GUICtrlRead($Input2) = "" Or GUICtrlRead($Input3) = "" Or GUICtrlRead($Input4) = "" Then
                            MsgBox(48, $Title & "-Warning", "Please fill the all required fields")
                        Else
                            adminupdate()
                        EndIf
                    Case $GUI_EVENT_CLOSE
                        ExitLoop
                EndSwitch
        EndSwitch
    WEnd

    GUIDelete($GUI1)
    GUICtrlSetData($Show, "Show")
    GUICtrlSetState($Administrator, $GUI_SHOW)

EndFunc   ;==>update

Func adminupdate()
    $Add = _GUICtrlListView_GetItemCount($ListView)
    GUICtrlCreateListViewItem($Add + 1 & "|" & GUICtrlRead($Input) & "|" & GUICtrlRead($Input2) & "|" & GUICtrlRead($Input3) & "|" & GUICtrlRead($Input4), $ListView)
    $msgbox = MsgBox(68, $Title & "-updater", "Do you want to add more?")
    If $msgbox = 6 Then
        clear()
    EndIf
EndFunc   ;==>adminupdate

Func clear()
    GUICtrlSetData($Input, "")
    GUICtrlSetData($Input2, "")
    GUICtrlSetData($Input3, "")
    GUICtrlSetData($Input4, "")
EndFunc   ;==>clear

As always if you have questions, please ask. :graduated:

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

i had a look on that tutorial... but might have understood properly where to use that GUICTRLSETSTAT() function :graduated: ....


Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Share this post


Link to post
Share on other sites

Hi Melba23,

I have one question in the above code i have option to display message like below

Func adminupdate()
    $Add = _GUICtrlListView_GetItemCount($ListView)
    GUICtrlCreateListViewItem($Add + 1 & "|" & GUICtrlRead($Input) & "|" & GUICtrlRead($Input2) & "|" & GUICtrlRead($Input3) & "|" & GUICtrlRead($Input4), $ListView)
    $msgbox = MsgBox(68, $Title & "-updater", "Do you want to add more?");Look at this line <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    If $msgbox = 6 Then
        clear()
    EndIf
EndFunc   ;==>adminupdate

if i click on "Cancel" the Updater GUI windows has to close autmoatically and i should be able to control the Client GUI. is that possible ? i tried upto my knowledge but i couldnt succeed :graduated:


Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Share this post


Link to post
Share on other sites

Syed23,

Use a return value from the function to determine what you do next: :graduated:

While 1
        $amsg = GUIGetMsg(1)
        Switch $amsg[1]
            Case $GUI1
                Switch $amsg[0]
                    Case $OK
                        If GUICtrlRead($Input) = "" Or GUICtrlRead($Input2) = "" Or GUICtrlRead($Input3) = "" Or GUICtrlRead($Input4) = "" Then
                            MsgBox(48, $Title & "-Warning", "Please fill the all required fields")
                        Else
                            If adminupdate() Then ; Run the function and see what we get as a return value <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                                ExitLoop ; It was True so we exit <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                            EndIf 
                        EndIf
                    Case $GUI_EVENT_CLOSE
                        ExitLoop
                EndSwitch
        EndSwitch
    WEnd

    GUIDelete($GUI1)
    GUICtrlSetData($Show, "Show")
    GUICtrlSetState($Administrator, $GUI_SHOW)

EndFunc   ;==>update

Func adminupdate()
    $Add = _GUICtrlListView_GetItemCount($ListView)
    GUICtrlCreateListViewItem($Add + 1 & "|" & GUICtrlRead($Input) & "|" & GUICtrlRead($Input2) & "|" & GUICtrlRead($Input3) & "|" & GUICtrlRead($Input4), $ListView)
    $msgbox = MsgBox(68, $Title & "-updater", "Do you want to add more?")
    If $msgbox = 6 Then
        clear()
        Return False ; We need to run again <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    EndIf
    Return True ; We need to exit <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
EndFunc   ;==>adminupdate

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

#6 ·  Posted (edited)

Here is my last question for this thread! I have 4 columns of listview with more than 10 rows of datas on each column. now i want to read the list view item for the particular column. what function will help? i serached on help file but i don;t find any special. what i found is i can read the the data for particular row of the first column. how to do it the same for other columns as well. Any clue?

Note: none of the items will be selected manually the data has to be retrived automatically..

Edited: Please appologise me - my question and the title does not match... but this is part of this same tool....

Edited by Syed23

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Share this post


Link to post
Share on other sites

Read the information from the row and find the portion that corresponds to the column you're looking for. The data you get is separated by the "|" character so you can do a stringsplit on the information and find which column you're looking for.


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

Share this post


Link to post
Share on other sites

Syed23,

i serached on help file but i don;t find any special

You need to sharpen up those searching skills! :)

Take a look at _GUICtrlListView_GetItemText again - notice the $iSubItem parameter? :graduated:

Or you could use _GUICtrlListView_GetItemTextArray and _GUICtrlListView_GetItemTextString - they get all the text of a ListView row and you can then extract the column you require. ;)

#include <GUIConstantsEx.au3>
#Include <GuiListView.au3>
#include <Array.au3>

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

$hLV = GUICtrlCreateListView("Col 1|Col2", 10, 10, 200, 200)

For $i = 0 To 9
    GUICtrlCreateListViewItem("Item " & $i & "|SubItem 1" & $i, $hLV)
Next

GUISetState()

ConsoleWrite("Row 0 Col 0: " & _GUICtrlListView_GetItemText($hLV, 0) & @CRLF)
ConsoleWrite("Row 0 Col 1: " & _GUICtrlListView_GetItemText($hLV, 0, 1) & @CRLF)

ConsoleWrite("Row 0 string: " & _GUICtrlListView_GetItemTextString($hLV, 0) & @CRLF)

$aArray = _GUICtrlListView_GetItemTextArray($hLV, 0)
_ArrayDisplay($aArray)

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

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

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