* Custom Message Box with hyperlink

For plugin authors to discuss plugin programming
Post Reply
User avatar
Mark1834
Megastar
Posts: 2146
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Custom Message Box with hyperlink

Post by Mark1834 » 16 May 2023 20:44

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
MessageBox.png (6.47 KiB) Viewed 1025 times
Facsimile.png
Facsimile.png (9.7 KiB) Viewed 1025 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?
Mark Draper

User avatar
tatewise
Megastar
Posts: 27075
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Custom Message Box with hyperlink

Post by tatewise » 17 May 2023 07:37

Mark, it would be useful to see the Lua/IUP script you are using to avoid having to recreate it all from scratch.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
jelv
Superstar
Posts: 364
Joined: 03 Feb 2020 22:57
Family Historian: V7
Location: Mere, Wiltshire

Re: Custom Message Box with hyperlink

Post by jelv » 17 May 2023 09:22

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()
John Elvin

User avatar
tatewise
Megastar
Posts: 27075
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Custom Message Box with hyperlink

Post by tatewise » 17 May 2023 09:38

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()
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Mark1834
Megastar
Posts: 2146
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: Custom Message Box with hyperlink

Post by Mark1834 » 17 May 2023 09:42

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.
Attachments
__Message Box with Hyperlink.fh_lua
(2.1 KiB) Downloaded 25 times
Mark Draper

User avatar
tatewise
Megastar
Posts: 27075
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Custom Message Box with hyperlink

Post by tatewise » 17 May 2023 10:01

The attached version has changed lines marked with -- +++++

It uses PARENTDIALOG=iupParent; DIALOGFRAME="YES"; as explained earlier.
Attachments
__Message Box with Hyperlink.fh_lua
(2.3 KiB) Downloaded 26 times
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Mark1834
Megastar
Posts: 2146
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: Custom Message Box with hyperlink

Post by Mark1834 » 17 May 2023 10:16

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
Facsimile2.png (8.27 KiB) Viewed 938 times
Mark Draper

User avatar
Mark1834
Megastar
Posts: 2146
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: Custom Message Box with hyperlink

Post by Mark1834 » 17 May 2023 17:28

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
Screenshot from 2023-05-17 18-19-38.png (11.6 KiB) Viewed 897 times
Screenshot from 2023-05-17 18-20-05.png
Screenshot from 2023-05-17 18-20-05.png (13.75 KiB) Viewed 897 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.
Mark Draper

User avatar
Valkrider
Megastar
Posts: 1533
Joined: 04 Jun 2012 19:03
Family Historian: V7
Location: Lincolnshire
Contact:

Re: Custom Message Box with hyperlink

Post by Valkrider » 17 May 2023 21:41

@Mark

Please see below from Mac version
Screenshot 2023-05-17 at 22.39.42.png
Screenshot 2023-05-17 at 22.39.42.png (119.47 KiB) Viewed 865 times
Screenshot 2023-05-17 at 22.40.04.png
Screenshot 2023-05-17 at 22.40.04.png (128.13 KiB) Viewed 865 times

User avatar
Mark1834
Megastar
Posts: 2146
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: Custom Message Box with hyperlink

Post by Mark1834 » 17 May 2023 22:36

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.
Mark Draper

User avatar
tatewise
Megastar
Posts: 27075
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Custom Message Box with hyperlink

Post by tatewise » 18 May 2023 10:31

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.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Mark1834
Megastar
Posts: 2146
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: Custom Message Box with hyperlink

Post by Mark1834 » 18 May 2023 12:52

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.
Mark Draper

avatar
jelv
Superstar
Posts: 364
Joined: 03 Feb 2020 22:57
Family Historian: V7
Location: Mere, Wiltshire

Re: Custom Message Box with hyperlink

Post by jelv » 18 May 2023 19:37

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
Text wrapping.png (4.51 KiB) Viewed 770 times
John Elvin

User avatar
Mark1834
Megastar
Posts: 2146
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: Custom Message Box with hyperlink

Post by Mark1834 » 18 May 2023 20:36

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?
Mark Draper

User avatar
tatewise
Megastar
Posts: 27075
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Custom Message Box with hyperlink

Post by tatewise » 18 May 2023 21:34

Yes Mark, I think you are correct. Native means Windows API.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

Post Reply