msgbox() function by the_winch15th Nov 2003 20:31
|
---|
Summary msbox() function with vb like sytax and constants Description Example Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com `vb style msgbox function ` `include in project and call like `i as integer `repeat `i = msgbox("Do you want to Exit?",MsgYesNo+MsgCritical,"Quit") `if i = MsgNo then wait 500 `until i = MsgYes ` `Based on vb msgbox function, see vb help or google for vb msgbox for usage info `or see this site. `http://www.w3schools.com/vbscript/func_msgbox.asp ` `Optional constants, rem them out if you don't use them. `opts (button) constants #constant MsgOKOnly = 0 #constant MsgOKCancel = 1 #constant MsgAbortRetryIgnore = 2 #constant MsgYesNoCancel = 3 #constant MsgYesNo = 4 #constant MsgRetryCancel = 5 ` #constant MsgCritical = 16 #constant MsgQuestion = 32 #constant MsgExclamation = 48 #constant MsgInformation = 64 ` #constant MsgDefaultButton1 = 0 #constant MsgDefaultButton2 = 256 #constant MsgDefaultButton3 = 512 ` #constant MsgApplicationModal = 0 #constant MsgSystemModal = 4096 `return values #constant MsgOK = 1 #constant MsgCancel = 2 #constant MsgAbort = 3 #constant MsgRetry = 4 #constant MsgIgnore = 5 #constant MsgYes = 6 #constant MsgNo = 7 `remend function msgbox(msg as string,opts as integer,title as string) `returns -1 if fail (all dll slots taken) local dll_num as integer : local hwnd as integer local response as integer dll_num = free_dll() if dll_num > 0 load dll "user32.dll",dll_num hwnd = call dll (dll_num,"GetActiveWindow") response = call dll (dll_num,"MessageBoxA",hwnd,msg,title,opts) delete dll dll_num else response = -1 endif endfunction response function free_dll() local i as integer : stop as integer repeat inc i if i < 256 then if dll exist(i)=0 then stop = 1 until stop = 1 or i > 255 if i > 255 then i = 0 endfunction i |