Created
December 20, 2009 03:15
-
-
Save rdp/260343 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ffi' | |
# button constants | |
BUTTONS_OK = 0 | |
BUTTONS_OKCANCEL = 1 | |
BUTTONS_ABORTRETRYIGNORE = 2 | |
BUTTONS_YESNO = 4 | |
# return code constants | |
CLICKED_OK = 1 | |
CLICKED_CANCEL = 2 | |
CLICKED_ABORT = 3 | |
CLICKED_RETRY = 4 | |
CLICKED_IGNORE = 5 | |
CLICKED_YES = 6 | |
CLICKED_NO = 7 | |
extend FFI::Library | |
ffi_lib 'user32' | |
ffi_convention :stdcall | |
attach_function :msgbox, 'MessageBoxA', [:pointer, :string, :string, :uint], :int | |
def message_box(txt, title=APP_TITLE, buttons=BUTTONS_OK) | |
r = msgbox(nil, txt, title, buttons) | |
return r | |
end | |
response = message_box("Are you sure you want to proceed?", | |
"Proceed?", BUTTONS_YESNO) | |
if response == CLICKED_YES | |
# insert your code here | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment