' -Project:mbdemo.pf3         Date:29/09/2004     Author:AAP
'----------------------------------------------------------------------------
'
'
'
'       Simple demo of a MessageBox() call
'
'
'
'
'- called by:
'
'- calls:
'
'- creates:
'
'- erases:
'
'- requires:
'
'
'
'----------------------------------------------------------------------------
'- Amendments
'
'  --/--/--    ???  .............
'----------------------------------------------------------------------------
'- external variables

'- external functions

'- public variables
'- MessageBox() Flags

'- public functions
public dll_messagebox(4)

'- external variables

'- external functions

'- global variables

'- global functions

'- public variables

'- public functions


main
local x
local MB_OK
local MB_OKCANCEL
local MB_ABORTRETRYIGNORE
local MB_YESNOCANCEL
local MB_YESNO
local MB_RETRYCANCEL
local MB_ICONHAND
local MB_ICONQUESTION
local MB_ICONEXCLAMATION
local MB_ICONASTERISK
local MB_ICONINFORMATION
local MB_ICONSTOP
local MB_DEFBUTTON1
local MB_DEFBUTTON2
local MB_DEFBUTTON3
local MB_APPLMODAL
local MB_SYSTEMMODAL
local MB_TASKMODAL
local MB_NOFOCUS
local MB_TYPEMASK
local MB_ICONMASK
local MB_DEFMASK
local MB_MODEMASK
local MB_MISCMASK

  '- MessageBox() Flags
  MB_OK               = 0x0000
  MB_OKCANCEL         = 0x0001
  MB_ABORTRETRYIGNORE = 0x0002
  MB_YESNOCANCEL      = 0x0003
  MB_YESNO            = 0x0004
  MB_RETRYCANCEL      = 0x0005
  MB_ICONHAND         = 0x0010
  MB_ICONQUESTION     = 0x0020
  MB_ICONEXCLAMATION  = 0x0030
  MB_ICONASTERISK     = 0x0040
  MB_ICONINFORMATION  = MB_ICONASTERISK
  MB_ICONSTOP         = MB_ICONHAND
  MB_DEFBUTTON1       = 0x0000
  MB_DEFBUTTON2       = 0x0100
  MB_DEFBUTTON3       = 0x0200
  MB_APPLMODAL        = 0x0000
  MB_SYSTEMMODAL      = 0x1000
  MB_TASKMODAL        = 0x2000
  MB_NOFOCUS          = 0x8000
  MB_TYPEMASK         = 0x000F
  MB_ICONMASK         = 0x00F0
  MB_DEFMASK          = 0x0F00
  MB_MODEMASK         = 0x3000
  MB_MISCMASK         = 0xC000

  '- OK returns     1
  '- Cancel returns 2
  '- Abort returns  3
  '- Retry returns  4
  '- Ignore returns 5
  '- Yes returns    6
  '- No returns     7

  x = dll_messagebox(0,"Testing 123","A test run",MB_OK)
message str(x)

  x = dll_messagebox(0,"Testing 123","Another test run",MB_ABORTRETRYIGNORE + MB_ICONHAND)
message str(x)

  x =  dll_messagebox(0,"Testing 123, but lets display lots and lots and lots of text this time.","Yet another test run",MB_RETRYCANCEL + MB_ICONEXCLAMATION)
message str(x)

  x =  dll_messagebox(0,"SORRY: Thats all folks.","Last another test run",MB_YESNOCANCEL + MB_ICONASTERISK)
message str(x)

end main





function dll_messagebox(hwnd,msg,title,style)
'- Returns a Windows standard value depending on the style & the user action.
local hwnd_angoss
local h_user32
local retval

  dll load "user32.dll" h_user32

  '- Get default windows handle
  dll call h_user32 function "GetActiveWindow"
  hwnd_angoss = getreg(ax)


  if hwnd = "NOTCHILD"
    '- Don't create messagebox as a child window. Practical upshot of this
    '- option is that window can be overlaid by angoss window, not a very
    '- desirable option. Angoss window is still locked until messagebox
    '- is cleared by user.
    hwnd = 0
  elseif value(hwnd) = 0
    hwnd = hwnd_angoss
  end if

  dll call h_user32 function "MessageBoxA" stack "LPPL" hwnd dosptr(msg) dosptr(title) style
  retval = getreg(ax)

  return(retval)

end function

