Sign in to follow this  
Followers 0
AppTux

Child windows

7 posts in this topic

I have a gui.

if you press a button, then opens a new gui.

now, the problem is, if you move the gui and the small gui is open, then the small gui have to go with the normal gui.

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.0.0
 Author:         AppTux

 Script Function:
    Run a program and open a folder, document or Internet Adress.

#ce ----------------------------------------------------------------------------

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIEdit.au3>
#include <File.au3>

Opt('MustDeclareVars', 1)

_WindowsTools_Run()

Func _WindowsTools_Run()
    Local $GUI,$GUIP,$pBAN,$pMIN,$pMIN2
    Local $Msg,$MOV,$ST = 0,$STW = 0
    Local $WINP,$LOCGUI,$lWT,$lRUN,$lRNO,$lROP
    
    $GUI =      GUICreate("WindowsTools Run",300,190)
    $GUIP =     WinGetPos($GUI)
        GUISetIcon("WindowsTools.ico",1,$GUI)
        GUISetBkColor(0xFFFFFF,$GUI)
        GUICtrlCreatePic("Data\Images\bk.bmp",0,20,300,170)
        GUICtrlSetState(-1,$Gui_Disable)
    ;------------------------------------------------Begin of Controls---------------------------------;
    $pBAN =     GUICtrlCreatePic("Data\Images\banner_run.bmp",0,0,300,20)
    $pMIN =     GUICtrlCreatePic("Data\Images\expand1.bmp",5,165,20,20)
    $pMIN2 =    GUICtrlCreatePic("Data\Images\min1.bmp",5,165,20,20)
        GUICtrlSetState($pMIN2,$GUI_HIDE)
    
    GUISetState()
    
    While 1
        $Msg = GUIGetMsg($GUI)
        $MOV = GUIGetCursorInfo($GUI)
        $WINP = WinGetPos($GUI)
        If $Msg = $GUI_EVENT_CLOSE Then
            Exit
        EndIf
        If $MOV[4] = $pMIN Then
            If $STW = 0 Then
                GUISetState(@SW_SHOW,$GUI)
                GUICtrlDelete($pMIN)
                $pMIN = GUICtrlCreatePic("Data\Images\expand2.bmp",5,165,20,20)
                GUICtrlSetState($pMIN,$GUI_SHOW)
                GUISetState(@SW_SHOW,$LOCGUI)
                While $MOV[4] = $pMIN
                    $Msg = GUIGetMsg()
                    If $Msg = $pMIN Then
                            GUICtrlSetState($pMIN2,$GUI_SHOW)
                        $WINP =     WinGetPos($GUI)
                        $LOCGUI =   GUICreate("Locations",150,188,$WINP[0] -150,$WINP[1] +28,$WS_POPUP,"",$GUI)
                            GUISetIcon("WindowsTools.ico",1,$LOCGUI)
                            GUISetBkColor(0xffffff,$LOCGUI)
                            GUICtrlCreatePic("Data\Images\bk.bmp",0,0,150,188)
                            GUICtrlCreatePic("Data\Images\treeexpand.bmp",5,6,9,9)
                        $lWT =      GUICtrlCreateLabel("WindowsTools",20,5,70,15)
                                GUICtrlCreatePic("Data\Images\treeexpand.bmp",15,23,9,9)
                        $lRUN =     GUICtrlCreateLabel("Run",30,22,50,15)
                                    GUICtrlCreateIcon("WindowsTools.ico",1,20,37,16,16)
                        $lRNO =     GUICtrlCreateLabel("Run",40,39,50,15)
                                    GUICtrlCreateIcon("WindowsToolsOpt.ico",1,20,56,16,16)
                        $lROP =     GUICtrlCreateLabel("Options",40,58,60,15)
                                
                                GUISetState()
                        GUICtrlSetState($pMIN,$GUI_HIDE)
                        $STW = 1
                    EndIf
                    $MOV = GUIGetCursorInfo($GUI)
                    Sleep(50)
                WEnd
                If $STW = 0 Then
                    GUISetState(@SW_SHOW,$GUI)
                    GUICtrlDelete($pMIN)
                    $pMIN = GUICtrlCreatePic("Data\Images\expand1.bmp",5,165,20,20)
                    GUICtrlSetState($pMIN,$GUI_SHOW)
                    GUISetState(@SW_SHOW,$LOCGUI)
                ElseIf $STW = 1 Then
                    GUICtrlSetState($pMIN,$GUI_HIDE)
                EndIf
            ElseIf $STW = 1 Then
                ;
            EndIf
        EndIf
    WEnd
EndFunc

not all of the functions work, but i can expand the gui

i hope i give enough information


PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore.

Share this post


Link to post
Share on other sites



AppTux,

I think you have just won the prize for the most unintelligible script I have seen this year! :evil:

I have tried to help out where I can - at least your secondary GUI now follows the main one. ;) I changed all the GUICtrlCreatePics into GUICtrlCreateButtons so I could see what was going on:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIEdit.au3>
#include <File.au3>

Opt('MustDeclareVars', 1)

_WindowsTools_Run()

Func _WindowsTools_Run()

    Local $GUI,$GUIP,$pBAN,$pMIN,$pMIN2
    Local $Msg,$MOV,$ST = 0,$STW = 0
    Local $WINP,$LOCGUI,$lWT,$lRUN,$lRNO,$lROP

    ; Create Main GUI
    $GUI = GUICreate("WindowsTools Run",300,190)
    $GUIP = WinGetPos($GUI)
        GUISetIcon("WindowsTools.ico",1,$GUI)
        GUISetBkColor(0xFFFFFF,$GUI)
        GUICtrlCreatePic("Data\Images\bk.bmp",0,20,300,170)
        GUICtrlSetState(-1,$Gui_Disable)
    ;------------------------------------------------Begin of Controls---------------------------------;
    $pBAN =     GUICtrlCreateButton("Run",0,0,300,20)
    $pMIN =     GUICtrlCreateButton("E1",5,165,20,20)
    $pMIN2 =    GUICtrlCreateButton("M",5,165,20,20)
        GUICtrlSetState($pMIN2,$GUI_HIDE)

    GUISetState()

    ; Create LOC GUI and hide
    $LOCGUI =   GUICreate("Locations",150,130,0,20,$WS_POPUP,$WS_EX_MDICHILD,$GUI) ; This is how you make a child wondow!! <<<<<<<<<<<<<<<<<<<<<<<<<
        GUISetIcon("WindowsTools.ico",1,$LOCGUI)
        GUISetBkColor(0xffffff,$LOCGUI)
        GUICtrlCreatePic("Data\Images\bk.bmp",0,0,150,188)
        GUICtrlCreatePic("Data\Images\treeexpand.bmp",5,6,9,9)
    $lWT =      GUICtrlCreateLabel("WindowsTools",20,5,70,15)
            GUICtrlCreatePic("Data\Images\treeexpand.bmp",15,23,9,9)
    $lRUN =     GUICtrlCreateLabel("Run",30,22,50,15)
                GUICtrlCreateIcon("WindowsTools.ico",1,20,37,16,16)
    $lRNO =     GUICtrlCreateLabel("Run",40,39,50,15)
                GUICtrlCreateIcon("WindowsToolsOpt.ico",1,20,56,16,16)
    $lROP =     GUICtrlCreateLabel("Options",40,58,60,15)

    GUISetState(@SW_HIDE, $LOCGUI)


    While 1
        ;$Msg = GUIGetMsg($GUI) ; $GUI is not a valid parameter <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        $Msg = GUIGetMsg()
        $MOV = GUIGetCursorInfo($GUI) ; Why??????????
        $WINP = WinGetPos($GUI) ; Why ?????????????????

        Switch $Msg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $pMIN
                If $STW = 0 Then
                    ;GUISetState(@SW_SHOW,$GUI) ; How can you press a control on this GUI if it is not already visible? <<<<<<<<<<<<<<<<<<<<<<<
                    GUICtrlDelete($pMIN)
                    $pMIN = GUICtrlCreateButton("E2",5,165,20,20)
                    ; GUICtrlSetState($pMIN,$GUI_SHOW) ; It is already visible by default
                    GUISetState(@SW_SHOW,$LOCGUI)
                    While $MOV[4] = $pMIN
                    ;$Msg = GUIGetMsg() ; you have already done this! <<<<<<<<<<<<<<<<<<<<<<<
                    ;If $Msg = $pMIN Then ; As the cursor is already on this control it is very likely that this will be true
                        GUICtrlSetState($pMIN,$GUI_HIDE)
                        GUICtrlSetState($pMIN2,$GUI_SHOW)
                        ;$WINP =     WinGetPos($GUI) ; You did this already! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                        $STW = 1
                    ;EndIf
                    ; $MOV = GUIGetCursorInfo($GUI) ; You did this already! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                        If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit ; You always need an exit in a loop!
                    WEnd
                    #cs
                If $STW = 0 Then ; This is the same condition as above!! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                    ;GUISetState(@SW_SHOW,$GUI) ; How can you press a control on this GUI if it is not already visible? <<<<<<<<<<<<<<<<<<<<<<<
                    GUICtrlDelete($pMIN)
                    $pMIN = GUICtrlCreateButton("E1",5,165,20,20)
                    GUICtrlSetState($pMIN,$GUI_SHOW)
                    GUISetState(@SW_SHOW,$LOCGUI)
                    #ce
                ElseIf $STW = 1 Then
                    GUICtrlSetState($pMIN,$GUI_HIDE)
                EndIf
            ;ElseIf $STW = 1 Then ; you just did this 3 lines above!!! <<<<<<<<<<<<<<<<<<<<<<<<<<<
                ;
            ;EndIf
        EndSwitch
    WEnd
EndFunc

Please try and rework the script before you come back for more help - that really hurt my head! :idea: Or try and explain what you want to happen - you are testing for an identical condition several times over. :evil:

See you soon, no doubt! :)

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 strange script.

I have now school holiday so I go to rewrite the script.

And change some things so you can understand it much more :evil:

But the rewriting can during a long, long time with a lot of bugs. ;)


PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore.

Share this post


Link to post
Share on other sites

AppTux,

I will be waiting! ;)

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 have this now:

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.0.0
 Author:         Gert-Jan van Ginkel
 Name:           WindowsTools Run

 Script Function:
    Run a program and open a folder, document or Internet Adress.

#ce ----------------------------------------------------------------------------

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

$WST = "Normal" ;The other GUI is not opened

$GUI =          GUICreate("WindowsTools",300,180)
                GUISetBkColor(0xFFFFFF)
$bEXP =         GUICtrlCreateButton("<<",0,155,25,25)

                
                GUISetState()
                
Do
    $Msg = GUIGetMsg()
    Switch $Msg
    Case $bEXP
        If $WST = "Normal" Then ;If the other GUI isn't opened.
            GUICtrlSetData($bEXP,">>")
            $GUI2 = GUICreate("",150,180,-152,25,$WS_POPUP,$WS_EX_MDICHILD,$GUI)
                    GUISetBkColor(0xFFFFFF)
                    GUICtrlCreatePic("Data\bk.bmp",0,0,150,180)
                    GUICtrlSetState(-1,$GUI_DISABLE)
                    
                    ; TREEVIEW ONE
                    $TREE = GUICtrlCreateTreeView(5, 5, 140, 170)
                    $TREEI1 = GUICtrlCreateTreeViewItem("WindowsTools", $TREE)
                    $T1RUN = GUICtrlCreateTreeViewItem("Run", $TREEI1)
                    $T1TCL = GUICtrlCreateTreeViewItem("Temp Cleaner",$TREEI1)
                    $TREEI2 = GUICtrlCreateTreeViewItem("Options", $TREE)
                    $T2RUN = GUICtrlCreateTreeViewItem("Run Options",$TREEI2)
                    GUICtrlSetState($TREEI1, $GUI_EXPAND)
                    GUICtrlSetState($TREEI2 ,$GUI_EXPAND)
                            
                    GUISetState()
            $WST = "Expanded" ;Set the value to Expanded so if you again press the button the GUI will be deleted.
        ElseIf $WST = "Expanded" Then ;If the other GUI is opened.
            GUICtrlSetData($bEXP,"<<")
            GUIDelete($GUI2)
            $WST = "Normal" ;Set the value to Normal so if you again press the button the GUI will be created again.
        EndIf
    EndSwitch
Until $Msg = $GUI_EVENT_CLOSE

I hope you can understand it now better.

The child windows works, but i have a really strange result:

do you have the same result?

because it does not matter what I want ;)


PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore.

Share this post


Link to post
Share on other sites

AppTux,

Good work! ;)

I have only one real comment - do not keep creating and destroying the second GUI - create it just the once and then Hide/Show it as required. The script below shows how.

I have also changed your GUIGetMsg loop slightly - there was nothing wrong with yours, but I prefer it this way! :evil:

#include <WindowsConstants.au3>

$WST = "Normal" ;The other GUI is not opened

$GUI = GUICreate("WindowsTools", 300, 180)
GUISetBkColor(0xFFFFFF, $GUI)
$bEXP = GUICtrlCreateButton("<<", 0, 155, 25, 25)

GUISetState(@SW_SHOW)

$GUI2 = GUICreate("", 150,180,-152,25, $WS_POPUP, $WS_EX_MDICHILD, $GUI)
GUISetBkColor(0xFFFF00, $GUI2)

$hPic = GUICtrlCreatePic("Data\bk.bmp", 0, 0, 150, 180)
GUICtrlSetState($hPic, $GUI_DISABLE)

; TREEVIEW ONE
$TREE = GUICtrlCreateTreeView(5, 5, 140, 170)
$TREEI1 = GUICtrlCreateTreeViewItem("WindowsTools", $TREE)
$T1RUN = GUICtrlCreateTreeViewItem("Run", $TREEI1)
$T1TCL = GUICtrlCreateTreeViewItem("Temp Cleaner", $TREEI1)
$TREEI2 = GUICtrlCreateTreeViewItem("Options", $TREE)
$T2RUN = GUICtrlCreateTreeViewItem("Run Options", $TREEI2)
GUICtrlSetState($TREEI1, $GUI_EXPAND)
GUICtrlSetState($TREEI2, $GUI_EXPAND)

GUISetState(@SW_HIDE)

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $bEXP
            If $WST = "Normal" Then ;If the other GUI isn't opened.
                GUICtrlSetData($bEXP, ">>")
                GUISetState(@SW_SHOW, $GUI2)
                $WST = "Expanded" ;Set the value to Expanded so if you again press the button the GUI will be deleted.
            ElseIf $WST = "Expanded" Then ;If the other GUI is opened.
                GUICtrlSetData($bEXP, "<<")
                GUISetState(@SW_HIDE, $GUI2)
                $WST = "Normal" ;Set the value to Normal so if you again press the button the GUI will be created again.
            EndIf
        EndSwitch

WEnd

The yellow colour for the second GUI was just so I could see it easily with my old eyes.

And NO I do not get the same effect as you - the small GUI follows its parent like a good child should. :evil:

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

Melba23,

That's what I wanted to hear.

I go look for the solution of the problem.

Maybe I have to look the solution in the drivers of my graphic card. I really don't know... ;)


PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore.

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