Links in mes, inp and other dialogs

QM 2.4.1. These standard dialog functions support links in static text: mes, inp, inpp, InputBox, ListDialog, MsgBoxAsync, ErrMsg. You can use links to show more info/help, run a file, open a web page, show a menu in inp, add more choices in mes, etc.

 

To enable links, the static text must begin with "<>". To insert links, you can use tags of 2 types:

 

The id links are like simple buttons. On click the dialog is closed and the dialog function returns retVal (a nonzero number). With mes, values 1-15 are mapped to button characters that match Windows API standard button constants, eg IDOK to 'O', IDCANCEL to 'C'.

 

The href links are used to execute any code. On click is called your callback function whose address is callbackAddress.

 

The callback function must begin with function# hwnd $params.

 

hwnd - dialog window handle.

params - tag text that follows callbackAddress and space.

 

If the callback function returns a nonzero value, the dialog is closed and the dialog function (mes etc) returns the value.

 

By default, text in these dialogs is displayed in Static control. Text with links is displayed in SysLink control. SysLink is unavailable in exe without manifest.

 

Examples

 add more choices in message box
sel mes("<>Question.[][]Other choices:[]<a id=''1000''>Maybe</a>" "" "YN?")
	case 'Y' out "Yes"
	case 'N' out "No"
	case 1000 out "Maybe"

 add popup menu in input box
str s
if(!inp(s F"<><a href=''{&sub.inp_link}''>select</a>")) ret
out s

#sub inp_link
function# hwnd $params
str items=
 one
 two
 three
int i=ShowMenu(items hwnd 0 2)
if(!i) ret
str si.getl(items i-1)
EditReplaceSel hwnd 4 si 3