[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

windows messagebox example(s

Brad Tilley

3/12/2006 2:56:00 AM

This is probably documented somewhere, but I thought ruby win32
programmers on the list may find this of use.

require 'Win32API'

def message_box
# Create a Windows MessageBox.
# 0 = 'OK' Button
# 1 = 'OK' 'Cancel' Buttons
# 2 = 'Abort' 'Retry' 'Ignore' Buttons
# 3 = 'Yes' 'No' 'Cancel' Buttons
# 4 = 'Yes' 'No' Buttons
# 5 = 'Retry' 'Cancel' Buttons
# 6 = 'Cancel' 'Try Again' 'Continue'
#######################
# 16 = 'OK' Button with 'Error' Symbol
# ... SEE ABOVE EXAMPLES
# 22 = 'Cancel' 'Try Again' 'Continue' Buttons with 'Error'
#######################################
# 32 = 'OK' Button with 'Question' Symbol
# ... SEE ABOVE EXAMPLES
# 38 = 'Cancel' 'Try Again' 'Continue' Buttons with 'Question'
#########################################
# 48 = 'OK' Button with 'Warning' Symbol
# ... SEE ABOVE EXAMPLES
# 54 = 'Cancel' 'Try Again' 'Continue' Buttons with 'Warning'
########################################
# 64 = 'OK' Button with 'Info' Symbol
# ... SEE ABOVE EXAMPLES
# 70 = 'Cancel' 'Try Again' 'Continue' Buttons with 'Info'
######################################
mb = Win32API.new("user32", "MessageBox", ['i','p','p','i'], 'i')
mb.call(0, 'message', "title", 0)
end

x = message_box
1 Answer

Yoann Guillot

3/12/2006 9:12:00 AM

0

> This is probably documented somewhere, but I thought ruby win32
> programmers on the list may find this of use.
>
> require 'Win32API'
>
> def message_box
<bunch of constants>
> mb = Win32API.new("user32", "MessageBox", ['i','p','p','i'], 'i')
> mb.call(0, 'message', "title", 0)
> end
>
> x = message_box
>

I personnaly prefer using DL::Importable :

require 'dl/import'

module User32
extend DL::Importable
dlload 'user32'
extern 'long MessageBox(long, char*, char*, long)'
end

User32.messageBox(0, 'i love dl', 'hello', 0)

--
Yoann Guillot