NAME=CustomNotice
AUTHOR=
ITEM=function CustomNotice$(title$, message$, buttons$)
DESCRIPTION=Function creates a custom messagebox with a title, message and up to 3
buttons specified in the arguments. Function returns text on the button pressed by
the user.
OUTSIDE CODE=
function CustomNotice$(title$, message$, buttons$)
'Arguments:
'title$ - text displayed on dialog caption
'message$ - text displayed in the dialog
'buttons$ - names of 1-3 buttons
if word$(buttons$, 1) <> "" then
yes$ = word$(buttons$, 1)
count = 1
else
exit function
end if
if word$(buttons$, 2) <> "" then
no$ = word$(buttons$, 2)
count = 2
end if
if word$(buttons$, 3) <> "" then
cancel$ = word$(buttons$, 3)
count = 3
end if
select case count
case 1
y = 120 : n = -80 : c = -80
case 2
y = 80 : n = 160 : c = -80
case 3
y = 40 : n = 120 : c = 200
end select
'calculate window/control dimensions based on message
'assuming 55 characters per line and 14 pixel line height
lineCount = int(len(message$)/55)+2
staticHeight = lineCount*14
buttonYOrg = staticHeight+30
WindowWidth = 320
WindowHeight = staticHeight+110
statictext #[Link], message$, 10, 20, 292, staticHeight
button #[Link], yes$, [yncYes], UL, y, buttonYOrg, 70, 25
button #ync, no$, [yncNo], UL, n, buttonYOrg, 70, 25
button #ync, cancel$, [yncCancel], UL, c, buttonYOrg, 70, 25
open title$ for dialog_modal as #ync
#[Link], "!font ms_sans_serif 9"
#ync, "trapclose [yncTrapclose]"
wait
[yncYes]
CustomNotice$ = yes$ : goto [yncTrapclose]
[yncNo]
CustomNotice$ = no$ : goto [yncTrapclose]
[yncCancel]
CustomNotice$ = cancel$
[yncTrapclose]
close #ync
end function