Sign in to follow this  
Followers 0
comradeb14ck

GUI Question

9 posts in this topic

Hey guys. I am doing something along these lines:

I have an application with a main GUI window. When I press a button, another GUI window is created.

What I want to do is make it so that when the new window is opened, it is impossible to get back to the main window without first closing this window. How can I do this? Thanks for your time and help.

-b14ck

Share this post


Link to post
Share on other sites



Hey guys. I am doing something along these lines:

I have an application with a main GUI window. When I press a button, another GUI window is created.

What I want to do is make it so that when the new window is opened, it is impossible to get back to the main window without first closing this window. How can I do this? Thanks for your time and help.

-b14ck

Mind posting your code?

You may try WinSetState("","",@SW_DISABLE)

Not sure if it's gonna work.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Sure, here is the code as it is now, although, I'm sure that it won't exactly work for you since you don't have the same pic files as I do.

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

 AutoIt Version: 3.2.2.0
 Author:         comradeb14ck (www.projectb14ck.org)

 Script Function:
    Update a user on woot.com's current item.

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

; Script Start - Add your code below here

#include <GuiConstants.au3>
$COLOR =                "red"; color of main window
$WINDOW_HEIGHT =        70; height of main window
$WINDOW_WIDTH =         400; width of main window
$PREFERENCES_HEIGHT =   20; width of preferences menu (added onto the GUI)

; GUI
GuiCreate("projectb14ck - woot checker", $WINDOW_WIDTH, $WINDOW_HEIGHT)
GuiSetIcon("PB.ico", 0)

; menu
$prefmenu =     GuiCtrlCreateMenu("&Preferences")

$colormenu =    GUICtrlCreateMenu("Color", $prefmenu, 1)
$optred =       GUICtrlCreateMenuItem("Red", $colormenu)
$optblue =      GUICtrlCreateMenuItem("Blue", $colormenu)
$optblack =     GUICtrlCreateMenuItem("Black", $colormenu)
$optwhite =     GUICtrlCreateMenuItem("White", $colormenu)
$optgreen =     GUICtrlCreateMenuItem("Green", $colormenu)
$optorange =    GUICtrlCreateMenuItem("Orange", $colormenu)
$optyellow =    GUICtrlCreatemenuItem("Yellow", $colormenu)

$sizemenu =     GUICtrlCreateMenu("Size", $prefmenu, 3)
$optcsize =     GUICtrlCreateMenuItem("Edit Size", $sizemenu)

$behaviormenu = GUICtrlCreateMenu("Behavior", $prefmenu, 4)
$optnormal =    GUICtrlCreateMenuItem("Normal", $behaviormenu)
$optontop =     GUICtrlCreatemenuItem("Always on Top", $behaviormenu)

$refreshmenu =  GUICtrlCreateMenu("Refresh Rate", $prefmenu, 5)
$optcrefresh =  GUICtrlCreateMenuItem("Edit Refresh Rate", $refreshmenu)

; new woot info
GuiCtrlCreatePic("PB.ico", 5, 5, $WINDOW_HEIGHT - 10, $WINDOW_HEIGHT - $PREFERENCES_HEIGHT - 10)
GuiCtrlCreateLabel("some woot item here $55.99 + $5 shipping and yaya some otheruff", $WINDOW_HEIGHT, 10, $WINDOW_WIDTH - $WINDOW_HEIGHT - 20, 25)

; GUI MESSAGE LOOP
GuiSetState()
While 1
    $msg = GUIGetMsg()
    
; change background color?
    If $msg = $optred Then
        GUISetBkColor(0xff0000)
    ElseIf $msg = $optblue Then
        GUISetBkColor(0x0000ff)
    ElseIf $msg = $optblack Then
        GUISetBkColor(0x000000)
    ElseIf $msg = $optwhite Then
        GUISetBkColor(0xffffff)
    ElseIf $msg = $optgreen Then
        GUISetBkColor(0x008000)
    ElseIf $msg = $optorange Then
        GUISetBkColor(0xffa500)
    ElseIf $msg = $optyellow Then
        GUISetBkColor(0xffff00)
    EndIf
    
; change the size?
    If $msg = $optcsize Then
        GUICreate("projectb14ck - edit size", 100, 100)
        GuiSetIcon("PB.ico", 0)
        
        GUISetState()
        While 1
            $msg2 = GUIGetMsg()
            
            If $msg2 = $GUI_EVENT_CLOSE Then ExitLoop
        WEnd
        GUIDelete()
    EndIf
    
; change font color?
    
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    
WEnd

I should probably add that the window I want to "force on top of the other one" so that the user cannot get back to the first window without first closing the new window is the window I create when the user clicks on the "Edit Size" button.

Edited by comradeb14ck

Share this post


Link to post
Share on other sites

bump

Share this post


Link to post
Share on other sites

Make your second GUI as child window of first GUI. Look into helpfile at GUICreate() parametres.

I'm using it in some of my projects.

But this way is not fully disabled accessibilty of first GUI, maybe @SW_DISABLED as someone posted above ...

Share this post


Link to post
Share on other sites

Sure, here is the code as it is now, although, I'm sure that it won't exactly work for you since you don't have the same pic files as I do.

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

 AutoIt Version: 3.2.2.0
 Author:         comradeb14ck (www.projectb14ck.org)

 Script Function:
    Update a user on woot.com's current item.

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

; Script Start - Add your code below here

#include <GuiConstants.au3>
$COLOR =                "red"; color of main window
$WINDOW_HEIGHT =        70; height of main window
$WINDOW_WIDTH =         400; width of main window
$PREFERENCES_HEIGHT =   20; width of preferences menu (added onto the GUI)

; GUI
GuiCreate("projectb14ck - woot checker", $WINDOW_WIDTH, $WINDOW_HEIGHT)
GuiSetIcon("PB.ico", 0)

; menu
$prefmenu =     GuiCtrlCreateMenu("&Preferences")

$colormenu =    GUICtrlCreateMenu("Color", $prefmenu, 1)
$optred =       GUICtrlCreateMenuItem("Red", $colormenu)
$optblue =      GUICtrlCreateMenuItem("Blue", $colormenu)
$optblack =     GUICtrlCreateMenuItem("Black", $colormenu)
$optwhite =     GUICtrlCreateMenuItem("White", $colormenu)
$optgreen =     GUICtrlCreateMenuItem("Green", $colormenu)
$optorange =    GUICtrlCreateMenuItem("Orange", $colormenu)
$optyellow =    GUICtrlCreatemenuItem("Yellow", $colormenu)

$sizemenu =     GUICtrlCreateMenu("Size", $prefmenu, 3)
$optcsize =     GUICtrlCreateMenuItem("Edit Size", $sizemenu)

$behaviormenu = GUICtrlCreateMenu("Behavior", $prefmenu, 4)
$optnormal =    GUICtrlCreateMenuItem("Normal", $behaviormenu)
$optontop =     GUICtrlCreatemenuItem("Always on Top", $behaviormenu)

$refreshmenu =  GUICtrlCreateMenu("Refresh Rate", $prefmenu, 5)
$optcrefresh =  GUICtrlCreateMenuItem("Edit Refresh Rate", $refreshmenu)

; new woot info
GuiCtrlCreatePic("PB.ico", 5, 5, $WINDOW_HEIGHT - 10, $WINDOW_HEIGHT - $PREFERENCES_HEIGHT - 10)
GuiCtrlCreateLabel("some woot item here $55.99 + $5 shipping and yaya some otheruff", $WINDOW_HEIGHT, 10, $WINDOW_WIDTH - $WINDOW_HEIGHT - 20, 25)

; GUI MESSAGE LOOP
GuiSetState()
While 1
    $msg = GUIGetMsg()
    
; change background color?
    If $msg = $optred Then
        GUISetBkColor(0xff0000)
    ElseIf $msg = $optblue Then
        GUISetBkColor(0x0000ff)
    ElseIf $msg = $optblack Then
        GUISetBkColor(0x000000)
    ElseIf $msg = $optwhite Then
        GUISetBkColor(0xffffff)
    ElseIf $msg = $optgreen Then
        GUISetBkColor(0x008000)
    ElseIf $msg = $optorange Then
        GUISetBkColor(0xffa500)
    ElseIf $msg = $optyellow Then
        GUISetBkColor(0xffff00)
    EndIf
    
; change the size?
    If $msg = $optcsize Then
        GUICreate("projectb14ck - edit size", 100, 100)
        GuiSetIcon("PB.ico", 0)
        
        GUISetState()
        While 1
            $msg2 = GUIGetMsg()
            
            If $msg2 = $GUI_EVENT_CLOSE Then ExitLoop
        WEnd
        GUIDelete()
    EndIf
    
; change font color?
    
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    
WEnd

I should probably add that the window I want to "force on top of the other one" so that the user cannot get back to the first window without first closing the new window is the window I create when the user clicks on the "Edit Size" button.

I suggest you use OnEvent mode as this gets way easier and I am able to help. I am not good with Msgloop mode.

Share this post


Link to post
Share on other sites
CODE
#cs ----------------------------------------------------------------------------

AutoIt Version: 3.2.2.0
Author:         comradeb14ck (www.projectb14ck.org)

Script Function:
    Update a user on woot.com's current item.

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

; Script Start - Add your code below here

#include <GuiConstants.au3>
$COLOR =                "red"; color of main window
$WINDOW_HEIGHT =         70; height of main window
$WINDOW_WIDTH =         400; width of main window
$PREFERENCES_HEIGHT =     20; width of preferences menu (added onto the GUI)

; GUI
$gui1 = GuiCreate("projectb14ck - woot checker", $WINDOW_WIDTH, $WINDOW_HEIGHT)
GuiSetIcon("PB.ico", 0)

; menu
$prefmenu =     GuiCtrlCreateMenu("&Preferences")

$colormenu =     GUICtrlCreateMenu("Color", $prefmenu, 1)
$optred =        GUICtrlCreateMenuItem("Red", $colormenu)
$optblue =        GUICtrlCreateMenuItem("Blue", $colormenu)
$optblack =        GUICtrlCreateMenuItem("Black", $colormenu)
$optwhite =        GUICtrlCreateMenuItem("White", $colormenu)
$optgreen =     GUICtrlCreateMenuItem("Green", $colormenu)
$optorange =     GUICtrlCreateMenuItem("Orange", $colormenu)
$optyellow =    GUICtrlCreatemenuItem("Yellow", $colormenu)

$sizemenu =     GUICtrlCreateMenu("Size", $prefmenu, 3)
$optcsize =        GUICtrlCreateMenuItem("Edit Size", $sizemenu)

$behaviormenu = GUICtrlCreateMenu("Behavior", $prefmenu, 4)
$optnormal =     GUICtrlCreateMenuItem("Normal", $behaviormenu)
$optontop =        GUICtrlCreatemenuItem("Always on Top", $behaviormenu)

$refreshmenu =     GUICtrlCreateMenu("Refresh Rate", $prefmenu, 5)
$optcrefresh =    GUICtrlCreateMenuItem("Edit Refresh Rate", $refreshmenu)

; new woot info
GuiCtrlCreatePic("PB.ico", 5, 5, $WINDOW_HEIGHT - 10, $WINDOW_HEIGHT - $PREFERENCES_HEIGHT - 10)
GuiCtrlCreateLabel("some woot item here $55.99 + $5 shipping and yaya some otheruff", $WINDOW_HEIGHT, 10, $WINDOW_WIDTH - $WINDOW_HEIGHT - 20, 25)

; GUI MESSAGE LOOP
GuiSetState()
While 1
    $msg = GUIGetMsg()
    
; change background color?
    If $msg = $optred Then
        GUISetBkColor(0xff0000)
    ElseIf $msg = $optblue Then
        GUISetBkColor(0x0000ff)
    ElseIf $msg = $optblack Then
        GUISetBkColor(0x000000)
    ElseIf $msg = $optwhite Then
        GUISetBkColor(0xffffff)
    ElseIf $msg = $optgreen Then
        GUISetBkColor(0x008000)
    ElseIf $msg = $optorange Then
        GUISetBkColor(0xffa500)
    ElseIf $msg = $optyellow Then
        GUISetBkColor(0xffff00)
    EndIf
    
; change the size?
    If $msg = $optcsize Then
        $gui2 = GUICreate("projectb14ck - edit size", 100, 100)
        GuiSetIcon("PB.ico", 0)
        GUISetState(@SW_DISABLE, $gui1)
        GUISetState(@SW_SHOW, $gui2)
        While 1
            $msg2 = GUIGetMsg()
            
            If $msg2 = $GUI_EVENT_CLOSE Then ExitLoop
            WEnd
            GUISetState(@SW_ENABLE, $gui1)
        GUIDelete($gui2)
    EndIf
    
; change font color?
    
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    
WEnd

Share this post


Link to post
Share on other sites

Ok, I was bored and changed the while loop and how the colors menu is created/functions.

CODE
#cs ----------------------------------------------------------------------------
    
    AutoIt Version: 3.2.2.0
    Author:         comradeb14ck (www.projectb14ck.org)
    
    Script Function:
    Update a user on woot.com's current item.
    
#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include <GuiConstants.au3>
$COLOR = "red"; color of main window
$WINDOW_HEIGHT = 70; height of main window
$WINDOW_WIDTH = 400; width of main window
$PREFERENCES_HEIGHT = 20; width of preferences menu (added onto the GUI)

; GUI
$gui1 = GUICreate("projectb14ck - woot checker", $WINDOW_WIDTH, $WINDOW_HEIGHT)
GUISetIcon("PB.ico", 0)

; menu
$prefmenu = GUICtrlCreateMenu("&Preferences")

$colormenu = GUICtrlCreateMenu("Color", $prefmenu, 1)

Dim $menu_items[8], $colors[8] = [7, 'Red', 'Blue', 'Black', 'White', 'Green', 'Orange', 'Yellow'], _
        $red = 0xff0000, $blue = 0x0000ff, $black = 0x000000, $white = 0xffffff, $green = 0x008000, $orange = 0xffa500, $yellow = 0xffff00
For $i = 1 To 7
    $menu_items[$i] = GUICtrlCreateMenuItem($colors[$i], $colormenu)
Next

$sizemenu = GUICtrlCreateMenu("Size", $prefmenu, 3)
$optcsize = GUICtrlCreateMenuItem("Edit Size", $sizemenu)

$behaviormenu = GUICtrlCreateMenu("Behavior", $prefmenu, 4)
$optnormal = GUICtrlCreateMenuItem("Normal", $behaviormenu)
$optontop = GUICtrlCreateMenuItem("Always on Top", $behaviormenu)

$refreshmenu = GUICtrlCreateMenu("Refresh Rate", $prefmenu, 5)
$optcrefresh = GUICtrlCreateMenuItem("Edit Refresh Rate", $refreshmenu)

GUICtrlCreatePic("PB.ico", 5, 5, $WINDOW_HEIGHT - 10, $WINDOW_HEIGHT - $PREFERENCES_HEIGHT - 10)
GUICtrlCreateLabel("some woot item here $55.99 + $5 shipping and yaya some otheruff", $WINDOW_HEIGHT, 10, $WINDOW_WIDTH - $WINDOW_HEIGHT - 20, 25)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $menu_items[1] To $menu_items[7]
            GUISetBkColor(Eval(GUICtrlRead($msg, 1)))
        Case $optcsize
            $gui2 = GUICreate("projectb14ck - edit size", 100, 100)
            GUISetIcon("PB.ico", 0)
            GUISetState(@SW_DISABLE, $gui1)
            GUISetState(@SW_SHOW, $gui2)
            While 1
                $msg2 = GUIGetMsg()
                If $msg2 = $GUI_EVENT_CLOSE Then ExitLoop
            WEnd
            GUISetState(@SW_ENABLE, $gui1)
            GUIDelete($gui2)
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

Thanks a lot for your help. I appreciate it a lot. =)

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