0% found this document useful (0 votes)
5 views2 pages

Custom Messagebox with Buttons

The document describes a function named CustomNotice that creates a custom message box with a specified title, message, and up to three buttons. It returns the text of the button pressed by the user and includes logic for handling different button configurations and window dimensions. The function is implemented in a programming language and includes detailed comments on its operation.

Uploaded by

olaadeleye184
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Custom Messagebox with Buttons

The document describes a function named CustomNotice that creates a custom message box with a specified title, message, and up to three buttons. It returns the text of the button pressed by the user and includes logic for handling different button configurations and window dimensions. The function is implemented in a programming language and includes detailed comments on its operation.

Uploaded by

olaadeleye184
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

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

You might also like