Sign in to follow this  
Followers 0
wraithdu

Toggle Button UDF

9 posts in this topic

#1 ·  Posted (edited)

I've been working on this one for a while now, tweaking here and there. A special thanks to Melba23 for his help in testing and suggestions.

This UDF creates two-state toggle buttons: click once to depress the button, click again to release it. They keyboard Space and Enter keys can also toggle the buttons. An optional user function is called on each state change and passed a parameter that can be used with the included functions to get information about the button that was clicked.

There are two versions of this UDF included in the archive with associated examples. One 'normal' UDF and a second written with AutoItObject (a big congrats to the AIO team!). Both are well documented and the examples are easy to follow.

Technical Note and Warning:

Most people who use this UDF can safely ignore the following. Under certain circumstances AutoIt can deadlock when calling a callback from within a callback (for example using SendMessage to send a subclassed button a message from within a mouse hook). I've experienced odd and inconsistent behavior in this regard. As it stands, both versions of the UDF work perfectly. However care should be taken when using these UDFs with other AutoIt callbacks in your scripts. This is especially true with the AutoItObject version since all AIO methods are implemented as callbacks.

ToggleButton.zip

Edited by wraithdu

Share this post


Link to post
Share on other sites



wraithdu,

Pleased to see that you did decide to release. :mellow: Nice to have a toggle other than the classic checkbox/radio.

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 (edited)

---

Edited by playlet

Share this post


Link to post
Share on other sites

Nice script!

But what is wrong with the default toggle button?

Global $gui = GUICreate("Test", 155, 155)
For $i = 0 To 15
 GUICtrlCreateCheckbox($i + 1, 10 + (35 * Mod($i, 4)), 10 + (35 * Floor($i / 4)), 30, 30, 0x1000) ;$BS_PUSHLIKE
Next

GUISetState()

Do
Until GUIGetMsg() = -3

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

... I'm gonna go shoot myself now.

Share this post


Link to post
Share on other sites

LOL

Couldn't get the udf to work. I got this:

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\Jon\Desktop\New folder\ToggleButton\button_ex3.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams

+>19:16:28 Starting AutoIt3Wrapper v.2.0.1.22 Environment(Language:0409 Keyboard:00000409 OS:WIN_7/ CPU:X64 OS:X86)

>Running AU3Check (1.54.14.0) params:-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 from:C:\Program Files\AutoIt3

C:\Users\Jon\Desktop\New folder\ToggleButton\ToggleButton.au3(336,42) : ERROR: OnAutoItExitRegister(): undefined function.

OnAutoItExitRegister("_ToggleButtonExit")

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Users\Jon\Desktop\New folder\ToggleButton\button_ex3.au3 - 1 error(s), 0 warning(s)

!>19:16:28 AU3Check ended.rc:2

>Exit code: 0 Time: 1.734


0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Get with the times! The UDF requires the newest release of AutoIt with the OnAutoItExitRegister function (not that it even matters anymore...).

Edited by wraithdu

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

corgano you should update your version of autoit, the error you have

ERROR: OnAutoItExitRegister(): undefined function.

is because 15th January, 2010 - v3.3.4.0

OnAutoItExit() has been removed. See the new functions OnAutoItExitRegister() and OnAutoItExitUnregister().

well done wraithdu, its good to see another exapmle of AutoItObject in action :mellow:

Edited by Yoriz

GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.

Share this post


Link to post
Share on other sites

If I copyright this:

OnAutoItExitRegister("OnAutoItExit")

can I please get $1 royalty every time somebody uses it?

Posted Image

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