Method: Fzeet::Dialog#initialize
- Defined in:
- lib/fzeet/windows/user/Window/Dialog.rb
#initialize(parent, opts = {}, &block) ⇒ Dialog
Returns a new instance of Dialog.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/fzeet/windows/user/Window/Dialog.rb', line 28 def initialize(parent, opts = {}, &block) @parent = parent _opts = { xstyle: [:noparentnotify], caption: Application.name, style: [:sysmenu, :visible], x: 0, y: 0, width: 200, height: 150, modal: false } badopts = opts.keys - _opts.keys; raise "Bad option(s): #{badopts.join(', ')}." unless badopts.empty? _opts.merge!(opts) _opts[:xstyle] = Fzeet.flags(_opts[:xstyle], *self.class::Prefix[:xstyle]) _opts[:caption] = _opts[:caption].to_s _opts[:style] = Fzeet.flags(_opts[:style], *self.class::Prefix[:style]) @messages ||= {} @commands ||= {} @notifies ||= {} @processed = [0, 0] dt = Windows::DLGTEMPLATE.new dt[:style] = _opts[:style] dt[:dwExtendedStyle] = _opts[:xstyle] dt[:x] = _opts[:x] dt[:y] = _opts[:y] dt[:cx] = _opts[:width] dt[:cy] = _opts[:height] on(:initdialog) { self.text = _opts[:caption] } on(:initdialog, &block) if block unless _opts[:modal] @handle = Windows.DetonateLastError(FFI::Pointer::NULL, :CreateDialogIndirectParam, Windows.GetModuleHandle(nil), dt, @parent && @parent.handle, BasicWindow::DialogProc, object_id ) self.dialog = true else @result = Windows.DetonateLastError([-1, 0], :DialogBoxIndirectParam, Windows.GetModuleHandle(nil), dt, @parent && @parent.handle, BasicWindow::DialogProc, object_id ) end end |