sorry for the double post. I forgot to mark the original with a proper subject and so it'll be deleted.
This should theoretically work in DBC as well as DBPro. I've only tested it in DBPro though.
To use this function is rather simple
myval = msgbox("Title", "Message", type)
Below is he code and a usage example. Also, attached is a usage example project.
`message box type constants
global MBOK = 0x0
global MBOKCANCEL = 0x1
global MBABORTRETRYIGNORE = 0x2
global MBYESNOCANCEL = 0x3
global MBYESNO = 0x4
global MBRETRYCANCEL = 0x5
`the actual message box function
function msgbox(caption as string, msg as string, msgtype as dword)
returnval as dword
load dll "user32.dll", 1
hwnd as dword : hwnd = CALL DLL (1,"GetForegroundWindow")
returnval = call dll(1, "MessageBoxA", hwnd, msg, caption, msgtype)
delete dll 1
endfunction returnval
Usage example:
`message box type constants
global MBOK = 0x0
global MBOKCANCEL = 0x1
global MBABORTRETRYIGNORE = 0x2
global MBYESNOCANCEL = 0x3
global MBYESNO = 0x4
global MBRETRYCANCEL = 0x5
`do
main()
`loop
function main()
buttonpressed = msgbox("MsgBox Window Title", "Message goes here", MBOK)`change the MBOK to whatever type you want
if buttonpressed = 1
MsgBox("What You Pressed", "OK button Pressed", MBOK)
else
if buttonpressed = 2
MsgBox("What You Pressed", "CANCEL button Pressed", MBOK)
else
if buttonpressed = 3
MsgBox("What You Pressed", "ABORT button Pressed", MBOK)
else
if buttonpressed = 4
MsgBox("What You Pressed", "RETRY button Pressed", MBOK)
else
if buttonpressed = 5
MsgBox("What You Pressed", "IGNORE button Pressed", MBOK)
else
if buttonpressed = 6
MsgBox("What You Pressed", "YES button Pressed", MBOK)
else
if buttonpressed = 7
MsgBox("What You Pressed", "No button Pressed", MBOK)
endif
endif
endif
endif
endif
endif
endif
end
endfunction
function msgbox(caption as string, msg as string, msgtype as dword)
returnval as dword
load dll "user32.dll", 1
hwnd as dword : hwnd = CALL DLL (1,"GetForegroundWindow")
returnval = call dll(1, "MessageBoxA", hwnd, msg, caption, msgtype)
delete dll 1
endfunction returnval
We need elseifs so that a lot of block if/elses don't press so far to the right.
Nothing I say is intended to be rude. My autism means that I do not know what is rude and what isn't rude. I apologize if I seem rude. It is not my intention.