Tyranna

How to make a button with a checkbox

10 posts in this topic

#1 ·  Posted

I need to make a button with a checkbox.  The button will have a $BS-BITMAP on it.

Anything I make and position on the button disappears behind it when the mouse runs over it.

Share this post


Link to post
Share on other sites



#2 ·  Posted

Tyranna,

Can you explain why you wish to have a checkbox on a button? If we understand the purpose, we might be able to suggest an alternative solution - using the $BS_SPLITBUTTON style sounds as if it might fit the bill.

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

#3 ·  Posted

The Button is going to perform the function, and if the box is checked, then it will be monitored and activated automatically at

specified intervals by the script, so I will not have to push the button manually.  It allows me to perform the function once if I want, but

if I want it to run auto, I can check the box.

Share this post


Link to post
Share on other sites

#4 ·  Posted

Tyranna,

Why can you not just place the checkbox beside the button?

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

#5 ·  Posted

Because I want to make a compact , superior interface.

 

Share this post


Link to post
Share on other sites

#6 ·  Posted

Tyranna,

How about this SplitButton example as "a compact, superior interface"?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <MsgBoxConstants.au3>
#include <GuiMenu.au3>

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

$cSplitButton = GUICtrlCreateButton("Run Auto", 10, 10, 120, 30, $BS_SPLITBUTTON)

GUISetState()

GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cSplitButton
            _Run_Select()
    EndSwitch

WEnd

Func _Run_Select()
    Switch GUICtrlRead($cSplitButton)
        Case "Run Auto"
            MsgBox($MB_SYSTEMMODAL, "Selected", "Auto")
        Case "Run Once"
            MsgBox($MB_SYSTEMMODAL, "Selected", "Once")
    EndSwitch
EndFunc

Func _Run_Menu($hCtrl)

    Local Enum $iOption_1 = 1000, $iOption_2
    Local $hMenu = _GUICtrlMenu_CreatePopup()
    _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Run Auto", $iOption_1)
    _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Run Once", $iOption_2)
    Switch _GUICtrlMenu_TrackPopupMenu($hMenu, $hCtrl, -1, -1, 1, 1, 2)
        Case $iOption_1
            GUICtrlSetData($cSplitButton, "Run Auto")
        Case $iOption_2
            GUICtrlSetData($cSplitButton, "Run Once")
    EndSwitch
    _GUICtrlMenu_DestroyMenu($hMenu)

    _Run_Select()

EndFunc   ;==>List_Insert_Menu

Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)

    #forceref $hWnd, $iMsg, $wParam

    Local $tStruct = DllStructCreate($tagNMHDR, $lParam)
    If @error Then Return
    Switch DllStructGetData($tStruct, "Code")
        Case $BCN_DROPDOWN
            _Run_Menu(DllStructGetData($tStruct, "hWndFrom"))
    EndSwitch
EndFunc

M23

1 person likes this

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

#7 ·  Posted

Dear @Melba23 that sure is pretty. :) 

nice code

Skysnake


Skysnake

Why is the snake in the sky?

Share this post


Link to post
Share on other sites

#8 ·  Posted

That is not bad, and it would probably do what i want, but what I am doing is mapping an 2 different images to the same button

depending if a flag is set, the flag is checked from within the message loop, and also the image is changed if it is in auto.

So,

0 and 0 = not active , not auto

0 and 1 = not active ,  auto

1 and 0 =  active , not auto

1 and 1 =  active ,  auto

Really , I wanted a Gold border around the button when selected , No border when not. (For Auto)

A dark image if the flag is not set. And a bright image when is set.

I ended up making 4 images to put on the button, 1 for every state and change it by checking both every time....

 

 

 

 

 

Share this post


Link to post
Share on other sites

#9 ·  Posted

Tyranna,

Glad you got what you wanted - even if it sounds a bit complicated.

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

#10 ·  Posted

There are some definite limitations for graphics manipulation in AutoIt.

Thanks for the Split Example , I saved it and will look at it further.  Probably will not use it for this specific project, but I like that functionality.

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