slightly-improved dialogs

Post a reply

Confirmation code
Enter the code exactly as it appears. All letters are case insensitive.
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :| :mrgreen: :geek: :ugeek: :arrow: :angel: :clap: :crazy: :eh: :lolno: :problem: :shh: :shifty: :sick: :silent: :think: :thumbup: :thumbdown: :salute: :wave: :wtf: :yawn: :facepalm: :bravo: :dance: :beard: :morebeard: :xmas: :HeHe: :trollface: :cookie: :rainbow: :monkeysee: :monkeysay: :happybday: :headwall: :offtopic: :superhappy: :terms: :beer:
View more smilies

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is ON
Smilies are ON

Topic review

Expand view Topic review: slightly-improved dialogs

Re: slightly-improved dialogs

Post by jeeswg » 09 Jun 2018, 08:06



Code: [Select all] [Expand]GeSHi © Codebox Plus


Code: [Select all] [Expand]GeSHi © Codebox Plus

Re: slightly-improved dialogs

Post by jeeswg » 09 Jun 2018, 07:45

- Some other general points:
- If in AHK v1/v2, you could overwrite a built-in function, but have the ability to still refer to that built-in function, that would be incredibly useful.
- Sometimes MsgBox/InputBox get hidden under other windows. I believe that this happens more in Windows 7 than it did in Windows XP.
- All of these dialog functions would benefit from a timeout option e.g. Progress/SplashImage/ToolTip. E.g. display a Progress ('SplashText') window for 3 seconds. I.e. sometimes a function gets interrupted, and the dialog remains on the screen permanently. And some options prevent a SetTimer event, to hide the dialog, from taking place.
- (Creating custom GUI functions in both AHK v1 and v2, that you can use in your libraries without automatically causing persistence. The built-in dialog functions don't cause persistence.)

Big work :o :thumbup: .
- Cool compliment, cheers.
no one wants a msgbox/inputbox/... in a critical thread anyways.
- The main script that I use more than any other, every day, which displays an InputBox with multiple choices, requires Critical/Thread-Priority be set. I may have done this to protect variables being overwritten by other subroutines.
- Anyhow, I might rewrite it to avoid the use of Critical/Thread-Priority, however, I think it's important to point out that built-in GUI functions appear to have an advantage here over custom functions.
Your functions depend on a number of global variables not supplied with the functions, that is annoying.
- Yeah, I've fixed this in the new version below. I did think of it at one point but forgot, I'd been really focused on the Progress/SplashImage functions which took 3 months to finally finish, but which didn't need special variables.
- I've also added in support for & (accelerator keys) in MsgBoxNew. Something that I noticed was missing just now when running the test script.

Re: slightly-improved dialogs

Post by Helgef » 08 Jun 2018, 14:01

Big work :o :thumbup: .
If I set Critical or Thread-Priority, and then called the InputBox function, I was unable to close the InputBox.

Critical wrote:Prevents the current thread from being interrupted by other threads, or enables it to be interrupted.
Gui events spawns new thread.
I don't know if there is a solution to this problem.
Turn off critical. For thread priority it seems you cannot restore it afterwards, but it should be rare. Alternatively you can create your dialogs in new threads, then you do not need to consider the settings in the calling thread. Or just do nothing, no one wants a msgbox/inputbox/... in a critical thread anyways. And it is not a problem, it is a feature of threads ;).

Your functions depend on a number of global variables not supplied with the functions, that is annoying.

Quick tips, gui and gui control event callbacks gets passed the object for which the event occured, eg, Gui_Close(Gui). And gui control objects can get their parent gui via the gui property, eg, myGui := myCtrl.gui. In gui event threads, the last found window is set to the gui for which the event occured.

Cheers, and thanks for sharing.

Re: slightly-improved dialogs

Post by jeeswg » 08 Jun 2018, 06:44

- I now have a full set of examples for slightly-improved dialogs.

1 MsgBox [big font]
2 InputBox (+ InputBox multi) [big font/multiple fields]
- The custom functions demonstrate the functionality that I wanted.
- (In theory I would have recreated MsgBox's Windows 7 appearance exactly, down to the pixels, but the numbers appeared wildly unpredictable.)

3 Progress [i.e. SplashText] [no additional features]
4 SplashImage [option to use IE control]
- The custom functions are virtually identical appearance-wise to the originals, although I would be happy for them to be even closer. The same applies to InputBox.

5 ToolTip [big font]
6 Borders [show coloured borders around a rectangle]
- I'm quite happy with these functions.

- Some general points:
- One issue that emerged was the need for consistency re. '0xABCDEF' v. 'ABCDEF'. The former allows hex or dec to be used, so no conversion is needed, and it allows the use of double quotes to be avoided.
- I experienced a major problem relating to Critical and Thread-Priority. If I set Critical or Thread-Priority, and then called the InputBox function, I was unable to close the InputBox. I don't know if there is a solution to this problem. There is an example of it amongst the examples below.

- Re. Progress/SplashImage:
- I judge Progress(/SplashText) and SplashImage to be sufficiently useful, non-trivial to implement, and long (thus inconvenient for inclusion at the bottom of a script or in the documentation), to be worth keeping as built-in functions. Having them as somehow 'semi-official' but not built-in, suggests that they are official, but that a random barrier has been put in place to burden newbies and spawn support threads in the forums. If they were to be 'kept' in some form, ideally they'd be as easy to use as MsgBox or InputBox.
- I find them to be versatile general purpose workhorse functions, useful for writing and sharing quick scripts, displaying large/custom fonts, and notifying me of events. If they were semi-deprecated, I'd end up with multiple incompatible snippets of code, and spending a disproportionate amount of time writing small GUI scripts for personal use and for sharing. If I felt that I wanted to keep using the P and S functions in some form, but that they weren't standard for sharing on the forum, I could also waste time converting code every time I wanted to share something. If anyone has any instincts for keeping them, they could consider any changes/additions to further increase their attractiveness.


Code: [Select all] [Expand]GeSHi © Codebox Plus


Code: [Select all] [Expand]GeSHi © Codebox Plus

Re: slightly-improved dialogs

Post by jeeswg » 26 May 2018, 22:57

- What would be better re. recreating SplashImage: using a Static control (closer to what a user would do) or drawing the image each time the window is activated (closer to the AHK v1 source code)?
- There are examples of both here:
no-frills SplashImage - AutoHotkey Community
- [EDIT:] For the custom SplashImage function below I've used a Static control.

Re: slightly-improved dialogs

Post by jeeswg » 27 Mar 2018, 23:49

- @nnnik: Part of the focus of this thread, is re. recreating Progress and SplashImage in AHK v2. It had been stated that they should be reborn as custom functions instead of built-in functions.
- (I don't mind if 0% of my code is used, I just hope to try and identify some of the problems, and some of the solutions, and hopefully speed up the eventual release of the finalised code.)
- The aim is more to discuss some of the programming issues through examples, rather than to make pretty GUIs. Maybe at some future point, the thread can be moved, but, as I see it, right now, it wouldn't be appropriate.
- The project is almost complete, just that I want to double-check the Progress/SplashImage functions, and convert the Find dialog to AHK v2.

- I found some key GUI links, that I thought I might share:

[MSDN: MsgBox]
[details for AHK's MsgBox command]
MessageBox function (Windows)
[MsgBox plus icon, mentioned in: 'MsgBox with custom icon (from resource)']
MessageBoxIndirect function (Windows)
[MsgBox sounds][this overlaps with AHK's SoundPlay function]
MessageBeep function (Windows)

[MSDN: AdjustWindowRectEx]
[from the source code for Progress/SplashImage]
[calculate window size based on client size and window style/ex. style (and vice versa)]
AdjustWindowRectEx function (Windows)
[apparently AdjustWindowRectEx can do both client size to/from window size based on window style/ex. style]
What is the inverse of AdjustWindowRect and AdjustWindowRectEx? – The Old New Thing
[AdjustWindowRectEx example]
measure Menu/ToolTip/GUI dimensions before showing - AutoHotkey Community

[MSDN: work area]
[from the source code for Progress/SplashImage]
[SPI_GETWORKAREA: get screen size minus (horizontal/vertical) taskbar size]
SystemParametersInfo function (Windows)
This functionality is built-in in AutoHotkey as SysGet-MonitorWorkArea, see here:
AutoHotkey via DllCall: AutoHotkey functions as custom functions - AutoHotkey Community

MagicBox - Message Box Generator - AutoHotkey Community

InputBox() - easy & powerful InputBox implementation - Scripts and Functions - AutoHotkey Community

Class: InputBoxEx - Customizable InputBox - Scripts and Functions - AutoHotkey Community
Help with InputBoxEx - AutoHotkey Community
EntryForm() - easy, custom InputBox, data entry forms - AutoHotkey Community

AHKv2: Diálogos para seleccionar Icono, Fuente, Color y Más! [23/07/17] - AutoHotkey Community

ToolTips: set border colour (custom font/colour ToolTips) (borders around windows/controls) - AutoHotkey Community
no-frills SplashImage - AutoHotkey Community
no-frills Progress/SplashText/ToolTip alternative - AutoHotkey Community
slightly-improved dialogs - AutoHotkey Community
Find dialog with whole word and RegEx support - AutoHotkey Community

[just me]
ToolTipEx - custom fonts and colors in ToolTips - AutoHotkey Community

ToolTipFont / ToolTipColor - options for the ToolTip command - AutoHotkey Community
MsgBox with custom icon (from resource) - AutoHotkey Community

- I'd be interested as to whether the system-wide text for the MsgBox buttons could be changed/retrieved. And also text like 'New Folder' and 'Copy of'. I had done some searching in the past but had not found anything.
- In the AutoHotkey source code, Progress and SplashImage are both defined within one function called Splash() within script2.cpp.

Re: slightly-improved dialogs

Post by nnnik » 07 Mar 2018, 02:42

I think this would be better off in the Scripts forum.

Re: slightly-improved dialogs

Post by jeeswg » 06 Mar 2018, 19:47

First attempt which currently only covers InputBox.

Code: [Select all] [Expand]GeSHi © Codebox Plus

[EDIT:] Added to 'NOTES' re. 'Close' event.