Page 1 of 1
Custom Message Box with hyperlink
Posted: 16 May 2023 20:44
by Mark1834
I'm experimenting with creating a custom Message Box containing a hyperlink. It's fairly straightforward to get something close to the standard IUP Message Box, but there are a couple of slightly annoying differences that I can't resolve.

- MessageBox.png (6.47 KiB) Viewed 1015 times

- Facsimile.png (9.7 KiB) Viewed 1015 times
The icons are slightly different, presumably because the IUP Lua Image Library uses older versions of the standard Windows icons, but I suspect we are stuck with that.
More frustratingly, I can't work out how to get rid of the Menu Box (top left corner) while still retaining the Close button (top right). The IUP documentation suggests that it is possible using DIALOGFRAME, but I can't get it to work.
Has anybody ever implemented it successfully?
Re: Custom Message Box with hyperlink
Posted: 17 May 2023 07:37
by tatewise
Mark, it would be useful to see the Lua/IUP script you are using to avoid having to recreate it all from scratch.
Re: Custom Message Box with hyperlink
Posted: 17 May 2023 09:22
by jelv
I'd like to achieve the same. My relevant code is:
Code: Select all
local dialog = iup.dialog{
iup.vbox{
iup.frame{
iup.vbox{tglAncestrySync, tglOption2;
gap = 10, margin = '10x10'
};
title = 'Additional checks'
},
iup.hbox{
iup.fill{}, btnSave, btnCancel, iup.fill{};
normalizesize = 'BOTH',margin = 'x10', gap = 40
};
gap = 10, margin = '10x10'
};
resize = 'No', minbox = 'No', maxbox = 'No',
title = 'Name checking - options'
}
dialog:popup()
Re: Custom Message Box with hyperlink
Posted: 17 May 2023 09:38
by tatewise
The IUP documentation for the iup.dialog{...} attribute DIALOGFRAME says it only removes the MENUBOX if the PARENTDIALOG is defined.
So the following script seems to work but may need further investigation:
iupParent = iup.dialog { Title="Parent"; }
iupParent:map()
iupChild = iup.dialog{ Title="Child"; iup.button { Title="OK"; }; PARENTDIALOG=iupParent; DIALOGFRAME="YES"; }
iupChild:popup()
Re: Custom Message Box with hyperlink
Posted: 17 May 2023 09:42
by Mark1834
My demo plugin is attached. This defines the link and message, then displays a standard MessageBox, followed by the custom box with a link.
Elements such as the background box to control colour and defining the font as the standard Windows dialog font (for users who use a different default in FH7) are pure eye candy and don't affect function, but they make it look more professional. The standard Message box does that already, and also controls the line break in the message, but it's easy enough to define these as required to give the required appearance.
Re: Custom Message Box with hyperlink
Posted: 17 May 2023 10:01
by tatewise
The attached version has changed lines marked with -- +++++
It uses PARENTDIALOG=iupParent; DIALOGFRAME="YES"; as explained earlier.
Re: Custom Message Box with hyperlink
Posted: 17 May 2023 10:16
by Mark1834
Excellent, thanks Mike. I was vaguely on the right track, but went down a rabbit hole with passing handles around. I've also tidied the code to remove the unnecessary grey box (it's just the default form colour), so I'll add that to the released plugin, probably tomorrow.

- Facsimile2.png (8.27 KiB) Viewed 928 times
Re: Custom Message Box with hyperlink
Posted: 17 May 2023 17:28
by Mark1834
There is one minor wrinkle to be aware of. I tried the plugin when running in Linux Mint / Wine, and the native appearance of the Message Box is rather different, as well as having a shorter preferred line length.

- Screenshot from 2023-05-17 18-19-38.png (11.6 KiB) Viewed 887 times

- Screenshot from 2023-05-17 18-20-05.png (13.75 KiB) Viewed 887 times
It's not an issue for my plugin, but it might be worth bearing in mind for a more general application plugin.
I don't know how it would appear in a Mac emulator. Would one of our Mac users be able to download the latest version from above (which still has the Windows enforced line break) please and post pictures? All it does is put a couple of messages on screen, and doesn't either read or write to your project data.
Re: Custom Message Box with hyperlink
Posted: 17 May 2023 21:41
by Valkrider
@Mark
Please see below from Mac version

- Screenshot 2023-05-17 at 22.39.42.png (119.47 KiB) Viewed 855 times

- Screenshot 2023-05-17 at 22.40.04.png (128.13 KiB) Viewed 855 times
Re: Custom Message Box with hyperlink
Posted: 17 May 2023 22:36
by Mark1834
Thanks Colin, very helpful. Broadly similar to Linux/WINE, so plugin authors who are creating their own custom Message Boxes need to be aware of the differences between native Windows and running in an emulator/WINE. Fortunately, that is fairly easy to detect with a simple Registry read (as per the Windows backup/restore plugin).
It's only cosmetic rather than functional, but it's part of a plugin's look and feel and usability.
Re: Custom Message Box with hyperlink
Posted: 18 May 2023 10:31
by tatewise
Clearly, it gets tricky to format the message text appropriately.
In the examples, there is a forced linebreak after Plugin Store (except in the Linux Mint / Wine examples).
I tried to use the iup.label{ ... WORDWRAP='YES'; } option without any linebreak in the text but could not get it to work.
Re: Custom Message Box with hyperlink
Posted: 18 May 2023 12:52
by Mark1834
Me too! I gave up on word wrap a while ago, as it clearly doesn’t work as described.
I generally hard code line breaks, then work outwards for the rest of the form design. It’s only a potential issue for custom dialogs based on standard forms. Normal IUP message boxes are fine, but they will be calling the Windows API to do the alignment for them.
I’ll use it for all future “expiry date” prompts, but probably not much else. I’ve also switched to using IUP message boxes rather than fhMessageBox(). It’s much better behaved when running with an IUP form open, both in FH7 and FH6. It also gets away from the fixed title of fhMessageBox(), which IMO is an unnecessary constraint. I asked CP if that was by design or an oversight, but it was another one of those difficult questions that they didn’t respond to.
Re: Custom Message Box with hyperlink
Posted: 18 May 2023 19:37
by jelv
Success!
Code: Select all
local btnDiagReport = iup.button{
title = 'Test',
padding = '10x3'
}
function btnDiagReport:action()
end
local hboxDiagReport = iup.hbox{
btnDiagReport,
iup.flatlabel{
title = 'Lorem ipsum dolor sit amet consectetuer Curabitur id lorem Proin Nam. Lobortis metus quis quis id Curabitur magna laoreet pellentesque.',
textwrap = 'YES',
expand = 'VERTICAL',
size = '200x',
minsize = 'x45'
};
gap = 10,
alignment = 'ACENTER'
}
local btnClose = iup.button{
title = 'Close',
padding = '10x3',
tip = 'Return to main menu'
}
function btnClose:action()
selection = 0
return iup.CLOSE
end
local vboxUtilForm = iup.vbox{
iup.frame{
iup.vbox{
hboxDiagReport
}
},
iup.hbox{
iup.fill{}, btnClose, iup.fill{};
};
gap = 1, margin = '10x5'
}
local dialog = iup.dialog{
vboxUtilForm;
resize = 'No', minbox = 'No', maxbox = 'No',
title = 'Label text wrapping'
}
dialog:popup()
gives

- Text wrapping.png (4.51 KiB) Viewed 760 times
Re: Custom Message Box with hyperlink
Posted: 18 May 2023 20:36
by Mark1834
Nice one!
I'm not sure I understand the significance of the "flat" controls.
"... does not have native decorations ..." seems to mean that it looks different. That's obvious for button vs flatbutton, where one looks like a button and the other doesn't, but label/flatlabel look the same to me.
"...since it is not a native control it has more flexibility for additional options..." could do with being translated into English. Does "not native" mean it is not calling the standard Windows API, so by doing its own thing it can play by its own rules?
Re: Custom Message Box with hyperlink
Posted: 18 May 2023 21:34
by tatewise
Yes Mark, I think you are correct. Native means Windows API.