* Custom Message Box with hyperlink
- Mark1834
- Megastar
- Posts: 2145
- Joined: 27 Oct 2017 19:33
- Family Historian: V7
- Location: South Cheshire, UK
Custom Message Box with hyperlink
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.
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?
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
- tatewise
- Megastar
- Posts: 27074
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Custom Message Box with hyperlink
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
Re: Custom Message Box with hyperlink
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
- tatewise
- Megastar
- Posts: 27074
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Custom Message Box with hyperlink
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()
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
- Mark1834
- Megastar
- Posts: 2145
- Joined: 27 Oct 2017 19:33
- Family Historian: V7
- Location: South Cheshire, UK
Re: Custom Message Box with hyperlink
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.
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
- tatewise
- Megastar
- Posts: 27074
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Custom Message Box with hyperlink
The attached version has changed lines marked with -- +++++
It uses PARENTDIALOG=iupParent; DIALOGFRAME="YES"; as explained earlier.
It uses PARENTDIALOG=iupParent; DIALOGFRAME="YES"; as explained earlier.
- Attachments
-
__Message Box with Hyperlink.fh_lua- (2.3 KiB) Downloaded 25 times
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
- Mark1834
- Megastar
- Posts: 2145
- Joined: 27 Oct 2017 19:33
- Family Historian: V7
- Location: South Cheshire, UK
Re: Custom Message Box with hyperlink
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.
Mark Draper
- Mark1834
- Megastar
- Posts: 2145
- Joined: 27 Oct 2017 19:33
- Family Historian: V7
- Location: South Cheshire, UK
Re: Custom Message Box with hyperlink
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.
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.
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
- Valkrider
- Megastar
- Posts: 1533
- Joined: 04 Jun 2012 19:03
- Family Historian: V7
- Location: Lincolnshire
- Contact:
Re: Custom Message Box with hyperlink
@Mark
Please see below from Mac version
Please see below from Mac version
- Mark1834
- Megastar
- Posts: 2145
- Joined: 27 Oct 2017 19:33
- Family Historian: V7
- Location: South Cheshire, UK
Re: Custom Message Box with hyperlink
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.
It's only cosmetic rather than functional, but it's part of a plugin's look and feel and usability.
Mark Draper
- tatewise
- Megastar
- Posts: 27074
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Custom Message Box with hyperlink
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.
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
- Mark1834
- Megastar
- Posts: 2145
- Joined: 27 Oct 2017 19:33
- Family Historian: V7
- Location: South Cheshire, UK
Re: Custom Message Box with hyperlink
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.
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
Re: Custom Message Box with hyperlink
Success!
gives
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()
John Elvin
- Mark1834
- Megastar
- Posts: 2145
- Joined: 27 Oct 2017 19:33
- Family Historian: V7
- Location: South Cheshire, UK
Re: Custom Message Box with hyperlink
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?
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
- tatewise
- Megastar
- Posts: 27074
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Custom Message Box with hyperlink
Yes Mark, I think you are correct. Native means Windows API.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry