[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Ruby msgbox?

aidy

5/19/2006 8:49:00 AM

This may seem obvious to some of you guys, but have I got to use a
win32 dll to create a message box in a Ruby program?

Cheers

Aidy

3 Answers

Chris Hulan

5/19/2006 6:12:00 PM

0

I guess you could. Or you could use one of the GUI libs (Tk, wx, Fox)
and use their implementation of a messageBox

Cheers
Chris

Johnny Software

5/20/2006 3:32:00 AM

0

Tk is a really easy way to do that. Does not take much code, it is
portable, and there are widely available examples of Tk GUIs in Ruby
out there.

There are some examples of this in the "Programming Ruby" 2nd edition
book from Pragmatic Programmers.

If you see stuff like the following in your Ruby lib directory - where
ever that is on your Windows computer, you probably are set up to use
Tk from Ruby.

../1.8/test/unit/ui/tk
../1.8/tk
../1.8/tkextlib
../1.8/tkextlib/blt
../1.8/tkextlib/blt/tile
../1.8/tkextlib/bwidget
../1.8/tkextlib/ICONS
../1.8/tkextlib/itcl
../1.8/tkextlib/itk
../1.8/tkextlib/iwidgets
../1.8/tkextlib/tcllib
../1.8/tkextlib/tclx
../1.8/tkextlib/tile
../1.8/tkextlib/tkDND
../1.8/tkextlib/tkHTML
../1.8/tkextlib/tkimg
../1.8/tkextlib/tktable
../1.8/tkextlib/tktrans
../1.8/tkextlib/treectrl
../1.8/tkextlib/trofs
../1.8/tkextlib/vu
../1.8/tkextlib/winico

Tk is nicer to use than the bare bones Win32 API for GUIs because Tk
has a layout manager. So when window resizing occurs, layout of its
contents is updated sanely/automatically.

Digikata@gmail.com

5/22/2006 3:15:00 PM

0

If all you want is the standard message box, you could just access the
direct WinAPI function:

msgbox = Win32API.new( 'user32', 'MessageBox', ['i', 'p', 'p', 'i'],
'i' )
flags = 0 # 0, ok, 1, ok cancel, etc
result = msgbox.call(0, "message", "title", flags )

Lookup the MessageBox function on msdn to determine all the flags.
Note, this is probably the wrong way to go if you want more extended
gui interactions; at that point it would likely be more worth your time
to climb the learning curove on one of the other Ruby Gui bindings.

Cheers,
- alan