AutoHotkey Community

It is currently May 26th, 2012, 11:08 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: September 5th, 2008, 9:24 am 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 774
Location: Texas, USA
Preface
Yes, another "Custom MsgBox" function.

This function was inspired by all the "Custom MsgBox" scripts that were shared via the AutoHotkey forum. Many of the ideas and some code was extracted from posts written by Icarus and Roland. See the References section for more information. Thanks to everyone who contributed.


Introduction
When you need a general-purpose dialog window, the MsgBox command will usually do the job. If you don't like the default button names you can add a timer and a few ControlSetText commands to change the standard MsgBox button labels to whatever you want.

On occasion, the standard MsgBox dialog just doesn't cut it. You want a custom icon, different font, more buttons, etc., etc. In these cases, most developers (including myself) either do without or they create a custom GUI to do the job.

A function that creates a general-purpose dialog window has always been attractive to me. For the most part, I want something that looks and feels like the standard MsgBox dialog but I also want something that can be customized on the fly. I created the CMsgBox function to meet these requirements.


CMsgBox
A few of the key features include the following:
  • Default driven. All of the function parameters are optional. Some of the parameters are assigned default values if the developer does not assign a value, others are appended to a default initial value.
  • Icons. The function can display standard Msgbox icons ("User32.dll") or a custom icon. A custom icon can derived from the function default (usually "Shell32.dll"), the program's icon (if the script is compiled), or from the IconFile option.
  • Sounds. If the Sound option is enabled, the function can play standard MsgBox sounds or a custom sound file (SoundFile option).
  • Buttons position. Buttons can be left-justified, right-justified, or centered (default).
  • GroupBox option. If enabled, the GroupBox option draws a rectangular frame around the icon and message text controls.
  • Checkbox option. If enabled, the Checkbox option adds one or more checkboxes to the bottom left corner of the window. A common use for this option is to add a "Don't ask me again" checkbox.
  • Radio option. Same as the Checkbox option except radio buttons are used instead checkboxes.
All of the features, options, and default/initial values have been documented in the script.


Screenshots
Image

Image

Image

Image

Image


The Code
The pertinent files are as follows:The example script allows you toggle many of the function's options so that you can see how these options affect the CMsgBox window.


Issues/Considerations/Bugs
  • Preview release. Since this a preview release of the function, some of the code has not been optimized and there may be some residual debug code lying around. If there is any interest, these issues will be corrected in future releases.
  • Future stuff. The source may include documentation and/or code for (possible) future options (marked as "[Future]"). These options are either 1) not coded, 2) not working, or 3) have not been fully tested. Please do not use.
  • Functions. This script calls several other functions. For testing and evaluation purposes, the source for these functions has been included in the primary script. In future releases, some of these functions will be moved to separate modules.

Customizing
As I mentioned earlier, this function is default-driven by design. Some of the defaults are system or logical defaults but many represent my personal preferences. Yes, you can override the defaults by providing the appropriate parameter value but it probably makes more sense to change some of the default values to reflect your requirements.

Most (all?) of the default values are represented by static variables at the top of the function. Every variable should include a description to give you an idea what/how the default is used. Go crazy!


References
The following are forum posts that I used to research this mini-project. Thank you for your contribution.

A handy dialogue technique! (and colorful msgbox's ^_^)
http://www.autohotkey.com/forum/topic10248.html

A handy dialogue technique! (and colorful msgbox's ^_^) {Reply}
http://www.autohotkey.com/forum/viewtopic.php?p=63485#63485

Custom Buttons for MsgBox? {Reply}
http://www.autohotkey.com/forum/viewtopic.php?p=98701#98701

[Function] Custom Msgbox / Custom Buttons
http://www.autohotkey.com/forum/viewtopic.php?t=32367


Final Thoughts
I hope that someone finds this useful.

---------------------------------------------------------------------------
v0.1 (Preview):
Original release.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 5th, 2008, 11:57 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
This will be very useful for me, thank you very much.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 6th, 2008, 12:33 am 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
It's huge! And I love how ~1/2 of the file is documentation xD

Anyway, I am amazed at the number of capabilities this has. Great work!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 6th, 2008, 2:20 am 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 774
Location: Texas, USA
Thanks guys.

Sorry for the extended documentation. I tend to be a bit verbose at times.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 6th, 2008, 5:20 am 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
I think the more documentation the better. A user can easily cut out parts of it he doesn't want, but it's not as easy to figure out something that hasn't been documented.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 28th, 2008, 2:04 am 
just found and love it, is there a new version out?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 28th, 2008, 2:33 am 
Offline

Joined: June 26th, 2006, 6:14 pm
Posts: 1379
Location: USA
do you feel that you need one?? are there issues with the current version?

_________________
Image
ʞɔпɟ əɥʇ ʇɐɥʍ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 28th, 2008, 5:05 pm 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 774
Location: Texas, USA
Anonymous wrote:
just found and love it, is there a new version out?

I added a minor feature a while back but its so obscure that even I haven't found a use for it yet. Other than that, there have been no significant changes. If you have a feature request or if you find a bug, make a noise.

Thank you for your interest.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 28th, 2008, 5:16 pm 
plz make ist like thalons Too, with showing ahk code!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 28th, 2008, 5:17 pm 
p.s. look at quickAHK post ;)


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Exabot [Bot] and 10 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group