Jump to content
flagg777

Do not close IF forms are not completed

Recommended Posts

flagg777

Another easy question.

What is the best way to refuse closing a windows (Or hitting the "ok" button on the msg box) if the radio button and/or input box is not filled in?

 

Thanks again

 

 

Share this post


Link to post
Share on other sites
JLogan3o13

Grey out the control until the radio button is checked, or until input box <> ""

Edit: Hit submit too quickly. I am assuming you mean on a GUI form you have created, not an external application?

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
flagg777

"grey out the control"

;Date
            $Date = GUICtrlCreateInput("", 72, 80, 97, 24)
            GUICtrlSetFont(-1, 10, 400, 0, "Arial")
            Global $DateFLD = GUICtrlRead($Date)

 

and

 

If (GUICtrlRead($Radio1pos) = $GUI_CHECKED) Then
                    $sString &= "1|"
                    ;Get Score
                    $Script1 = 1

What do you mean "grey out"

 

-sorry, I'm a noob

 

Share this post


Link to post
Share on other sites
careca

Means disable, problem i see is that i can't think of a way to check the input until it's closed, i'd do it in a custom GUI.

Edited by careca

Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites
JLogan3o13

There are a couple of ways you could do it. Below is a quick and dirty (and I do mean that, am typing in notepad) using GUIOnEventMode. It should work to give you an idea of how to accomplish what you're after:

#include <GUIConstantsEx.au3>
Opt("GUIOnEventMode", 1)

    $hGUI = GUICreate("Test", 300, 300)
        GUISetOnEvent($GUI_EVENT_CLOSE, "GetOut")

    $btnGo = GUICtrlCreateButton("Next", 200, 250, 80, 40)
        GUICtrlSetState($btnGo, $GUI_DISABLE)

    $rbtnTest = GUICtrlCreateRadio("Test", 10, 10, 40, 30)
        GUICtrlSetOnEvent(-1, "_enable")

    GUISetState()

    While 1
        Sleep(100)
    WEnd

Func _enable()
    GUICtrlSetState($btnGo, $GUI_ENABLE)
EndFunc

Func GetOut()
    Exit
EndFunc

 

Edit: You could also do it like this, much easier:

#include <GUIConstantsEx.au3>


    $hGUI = GUICreate("Test", 300, 300)
    $btnGo = GUICtrlCreateButton("Next", 200, 250, 80, 40)
        GUICtrlSetState($btnGo, $GUI_DISABLE)
    $cbxTest = GUICtrlCreateCheckbox("Test", 10, 10, 40, 30)
    GUISetState()

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
            Case $cbxTest
                $i = GUICtrlRead($cbxTest)
                GUICtrlSetState($btnGo, ($i = 1) ? $GUI_ENABLE : $GUI_DISABLE)
        EndSwitch
    WEnd

 

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
flagg777

having trouble figuring this one out.. 

I tried to Frankenstein that code but it still does not disable the close button (or in my case the submit" button

II tested with adding

GUICtrlSetOnEvent(-1, "_enable")

to one of my buttons, I was able to close it out. I also added to the submit button as you specified and the button was not disabled.

GUICtrlSetState($btnGo, $GUI_DISABLE)

Alpha-v028.au3

Share this post


Link to post
Share on other sites
careca

So what are the conditions you want, for the submit button to be enabled? only the radiocheck's?


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites
flagg777

yes.

I would love to understand the code so I can add it to the text boxes.

 

Thanks for the help!

 

Share this post


Link to post
Share on other sites
careca

So you want the submit button to be disabled until one of the checkboxes is selected? Code has to be adapted but what i would do is check the radio buttons state in loop, and state a condition of if one is checked, enable submit. But it raises questions like if radios have to be on the enabled or disabled sides.


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites
flagg777

thanks

I will try that.

would you have an example?

I tried to digest Logan3013's example but can't see how to incorporate into my script.

 

Thanks again

Share this post


Link to post
Share on other sites
careca

Of course you have to adapt the code to yours.

While 1
                $SomeRadio1 = GUICtrlRead($cbxTest)
                If $SomeRadio1=$GUI_CHECKED Then

                GUICtrlSetState($btnGo, $GUI_ENABLE)
                Else

                GUICtrlSetState($btnGo, $GUI_DISABLE)
                EndIf

    WEnd

Now, i should mention, this was done at work, so you have to adapt this

$SomeRadio1=$GUI_CHECKED

To something else, $SomeRadio1 will retrieve a number when checked, another when unchecked, or you can compare it with GUICtrlGetState.

But it should give you an idea, it's basically what JLogan3o13 posted, but maybe you can understand it better.

Best regards.


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

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

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.