Location Earth, (I Think)
Home
About Us
Contact Us
Links
Home
Opening A Message Box, (User32.dll)
 
DarkBasic Lacks the ability to use Message Boxes automatically, so you may wish to call one from the Windows DLL, Below is the full code for this, along with an example, Just copy the contents of the panel below to DarkBasic and Press F5 and it will work instantly.
 
Also try messing arround with the Options to see the Different tupes of MsgBoxes Available to you.
 

` -------------------------------------------------------------------------
  #CONSTANT DLL_User32  3
  LOAD DLL "User32.dll",DLL_User32
` -------------------------------------------------------------------------

` MsgBox() Options -------------------
  #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 MsgDefaultBtn1      =    0
  #CONSTANT MsgDefaultBtn2      =  256
 
#CONSTANT MsgDefaultBtn3      =  512
` ------------------------------------
  #CONSTANT MsgApplicationModal =    0
  #CONSTANT MsgSystemModal      = 4096
` MsgBox() Return Values -------------
  #CONSTANT MsgOK               =    1
  #CONSTANT MsgCancel           =    2
  #CONSTANT MsgAbort            =    3
  #CONSTANT MsgRetry            =    4
  #CONSTANT MsgIgnore           =    5
  #CONSTANT MsgYes              =    6
  #CONSTANT MsgNo               =    7
` ------------------------------------

 

Result = MsgBox("Save Before Exiting?","Would you like to Save Changes before you Exit?",MsgYesNoCancel)

 

If Result = MsgYes    Then Print "You Pressed the YES Button"

If Result = MsgNo     Then Print "You Pressed the NO Button"

If Result = MsgCancel Then Print "You Pressed the CANCEL Button"

 

Do

Loop


 

`        --------------------------------------------------------------------------------------------------------------------

FUNCTION MsgBox(Title$,Msg$,Options) : ` Show a MessageBox, Returns Button Pressed
         hwnd   = CALL DLL(DLL_USER32,"GetActiveWindow")
         Result = CALL DLL(DLL_USER32,"MessageBoxA",hwnd,Msg$,Title$,Options)

ENDFUNCTION Result
`        --------------------------------------------------------------------------------------------------------------------

 

This page was last modified on Monday, 28 April 2008 10:23