Sign in to follow this  
Followers 0
gte

Drop down box menu help

13 posts in this topic

I have a drop down box made in koda, that triggers whether a button is greyed out or not.

What happens is that when I highlight the menu option guictrlcreatecombo($menu1) out of the drop down menu box, it triggers the button ($button1) to be enabled and I'd like it to only be enabled when the drop down box item is clicked (not highlighted) ... any ideas?

Also, I have a guictrlread($button1) to check and see if the button is enabled, and I have to use sleep(50) to keep it from being obnoxious like a strobe light (flickering), is there a better solution for this?

Thanks

Share this post


Link to post
Share on other sites



I have a drop down box made in koda, that triggers whether a button is greyed out or not.

What happens is that when I highlight the menu option guictrlcreatecombo($menu1) out of the drop down menu box, it triggers the button ($button1) to be enabled and I'd like it to only be enabled when the drop down box item is clicked (not highlighted) ... any ideas?

Also, I have a guictrlread($button1) to check and see if the button is enabled, and I have to use sleep(50) to keep it from being obnoxious like a strobe light (flickering), is there a better solution for this?

Thanks

can we see some code so we know how you're doing this


Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Share this post


Link to post
Share on other sites

gte,

I think this might be something like what you are looking for:

#include <GUIConstantsEx.au3>
#Include <GuiComboBox.au3>

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

$hCombo = GUICtrlCreateCombo("", 10, 10, 200, 20)
GUICtrlSetData(-1, "Item 1|Enable Button|Item 2")

$hButton = GUICtrlCreateButton("Test", 250, 10, 80, 30)
    GUICtrlSetState(-1, $GUI_DISABLE)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    
    If _GUICtrlComboBox_GetEditText($hCombo) = "Enable Button" Then
        If BitAnd(GUICtrlGetState($hButton), $GUI_DISABLE) Then GUICtrlSetState($hButton, $GUI_ENABLE)
    EndIf

WEnd

Only ENABLEs on selection and does not flicker. :-)

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

Slightly corrected Melba23 examlple.

#include <GUIConstantsEx.au3>
#include <GuiComboBox.au3>
#include <WindowsConstants.au3>

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

$hCombo = GUICtrlCreateCombo("", 10, 10, 200, 20)
GUICtrlSetData(-1, "Item 1|Enable Button|Item 2")

$hButton = GUICtrlCreateButton("Test", 250, 10, 80, 30)
GUICtrlSetState(-1, $GUI_DISABLE)

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

GUISetState()

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

Func WM_COMMAND($hWnd, $msgID, $wParam, $lParam)
    Switch BitAND($wParam, 0xFFFF)
        Case $hCombo
            Switch BitShift($wParam, 16)
                Case $CBN_SELCHANGE
                    If GUICtrlRead($hCombo) = "Enable Button" Then
                        If BitAND(GUICtrlGetState($hButton), $GUI_DISABLE) Then
                            GUICtrlSetState($hButton, $GUI_ENABLE)
                        EndIf
                    Else
                        If BitAND(GUICtrlGetState($hButton), $GUI_ENABLE) Then
                            GUICtrlSetState($hButton, $GUI_DISABLE)
                        EndIf
                    EndIf
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Share this post


Link to post
Share on other sites

Yashied,

I would prefer "slightly different" to "slightly corrected". I thought my version worked quite nicely. ;-)

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

Thanks all

Melba, I'm having a heck of a time implementing this to my current script. I know I didn't post my current script because I think it would have been more confusing, but I can do that if necessary.

Here is what I'm trying to replace with your style of code

Switch GuiCtrlRead($updatenoworcreateschtask)
        Case 'Make update NOW in real time'
            GUICtrlSetState($updatelibrarylistbutton, $GUI_ENABLE)
            GUICtrlSetState($createtaskbutton, $gui_disable)
                Sleep(500)
        Case 'Create a scheduled task for later'
            GUICtrlSetState($createtaskbutton, $GUI_ENABLE)
            GUICtrlSetState($updatelibrarylistbutton, $gui_disable)
                Sleep(500)
                
    EndSwitch

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

gte,

What are you reading with this line:

Switch GuiCtrlRead($updatenoworcreateschtask)

M23

Edit:

If it is the combo then this should work for you:

#include <GUIConstantsEx.au3>
#Include <GuiComboBox.au3>

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

$hCombo = GUICtrlCreateCombo("", 10, 10, 200, 20)
GUICtrlSetData(-1, "Item 1|Update NOW|Schedule Task|Item 4")

$hButton1 = GUICtrlCreateButton("Task", 250, 10, 80, 30)
    GUICtrlSetState(-1, $GUI_DISABLE)

$hButton2 = GUICtrlCreateButton("Update", 250, 50, 80, 30)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    
    Switch _GUICtrlComboBox_GetEditText($hCombo)
        Case "Update NOW"
            If BitAnd(GUICtrlGetState($hButton2), $GUI_DISABLE) Then GUICtrlSetState($hButton2, $GUI_ENABLE)
            If BitAnd(GUICtrlGetState($hButton1), $GUI_ENABLE)  Then GUICtrlSetState($hButton1, $GUI_DISABLE)
        Case "Schedule Task"
            If BitAnd(GUICtrlGetState($hButton1), $GUI_DISABLE) Then GUICtrlSetState($hButton1, $GUI_ENABLE)
            If BitAnd(GUICtrlGetState($hButton2), $GUI_ENABLE)  Then GUICtrlSetState($hButton2, $GUI_DISABLE)
    EndSwitch

WEnd
Edited by Melba23

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

gte,

Glad I could help!

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

If you don't mind ... another question on this topic

I'm trying to apply this coding technique to other inputboxes and I'm failing :)

Here is what I have, am I using the correct code?

Switch _GUICtrlButton_GetCheck($passwordinputcheckbox)
        Case $passwordinputcheckbox
            if guictrlread($passwordinputcheckbox = $gui_checked Then
                GUICtrlSetState($passwordinput, $GUI_ENABLE)
            EndIf

    EndSwitch

gte,

Glad I could help!

M23

Share this post


Link to post
Share on other sites

I think I figured it out!!

Switch _GUICtrlButton_GetCheck($usernameinputcheckbox)
        Case $BST_CHECKED
            If BitAnd(GUICtrlGetState($usernameinput), $GUI_DISABLE) Then GUICtrlSetState($usernameinput, $GUI_ENABLE)
        
        Case $BST_UNCHECKED
            If BitAnd(GUICtrlGetState($usernameinput), $GUI_ENABLE) Then GUICtrlSetState($usernameinput, $GUI_DISABLE)
    EndSwitch

Share this post


Link to post
Share on other sites

gte,

That looks as if it should work. If you do not check the current state, you will apply the required state on each loop and get the dreaded "flickering". It is a pain, but worth the effort. :-)

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