Class: Fzeet::CommonDialog
- Includes:
- WindowMethods
- Defined in:
- lib/fzeet/Dialog/Common.rb
Direct Known Subclasses
ColorDialog, FileDialog, FindReplaceDialog, FolderDialog, FontDialog
Constant Summary collapse
- HookProc =
-> klass, hwnd, uMsg, wParam, lParam { begin if klass == Windows::BROWSEINFO if uMsg == Windows::BFFM_IUNKNOWN instance = ObjectSpace._id2ref(lParam) if @@instances.include?(hwnd.to_i) @@instances.delete(hwnd.to_i) else @@instances[hwnd.to_i] = instance @@instances[hwnd.to_i].instance_variable_set(:@handle, hwnd) end end else if uMsg == Windows::WM_INITDIALOG @@instances[hwnd.to_i] = ObjectSpace._id2ref( klass.new(FFI::Pointer.new(lParam))[:lCustData].to_i ) @@instances[hwnd.to_i].instance_variable_set(:@handle, hwnd) end end result = @@instances[hwnd.to_i].hookProc(hwnd, uMsg, wParam, lParam) if @@instances[hwnd.to_i] rescue answer = Fzeet. %Q{#{$!}\n\n#{$!.backtrace.join("\n")}}, buttons: [:abort, :retry, :ignore], icon: :error Application.quit if answer.abort? ensure if uMsg == Windows::WM_NCDESTROY @@instances.delete(hwnd.to_i) end end result || 0 }
Constants included from WindowMethods
Instance Attribute Summary collapse
-
#struct ⇒ Object
readonly
Returns the value of attribute struct.
Attributes inherited from Handle
Class Method Summary collapse
Instance Method Summary collapse
- #hookProc(hwnd, uMsg, wParam, lParam) ⇒ Object
-
#initialize ⇒ CommonDialog
constructor
A new instance of CommonDialog.
- #on(msg, &block) ⇒ Object
Methods included from WindowMethods
#[], #capture=, #capture?, #dialog=, #dialog?, #dlgmsg?, #drawMenuBar, #eachChild, #enabled=, #enabled?, #focus=, #focus?, #invalidate, #location, #location=, #long, #menu, #menu=, #message, #paint, #position, #position=, #postmsg, #question, #rect, #reframe, #sendmsg, #show, #size, #size=, #style, #style?, #text, #text=, #textlen, #topmost=, #topmost?, #update, #visible=, #visible?, #xstyle, #xstyle?
Methods included from Toggle
Methods inherited from Handle
#attach, #detach, #dup, instance, instance?, wrap
Constructor Details
#initialize ⇒ CommonDialog
Returns a new instance of CommonDialog.
61 62 63 |
# File 'lib/fzeet/Dialog/Common.rb', line 61 def initialize @messages = {} end |
Instance Attribute Details
#struct ⇒ Object (readonly)
Returns the value of attribute struct.
65 66 67 |
# File 'lib/fzeet/Dialog/Common.rb', line 65 def struct @struct end |
Class Method Details
.crackMessage(hwnd, uMsg, wParam, lParam) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/fzeet/Dialog/Common.rb', line 45 def self.crackMessage(hwnd, uMsg, wParam, lParam) window = @@instances[hwnd.to_i] args = { hwnd: hwnd, uMsg: uMsg, wParam: wParam, lParam: lParam, result: 0, window: window, sender: window } args end |
Instance Method Details
#hookProc(hwnd, uMsg, wParam, lParam) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/fzeet/Dialog/Common.rb', line 67 def hookProc(hwnd, uMsg, wParam, lParam) args, result = nil, nil if (handlers = @messages[uMsg]) args ||= self.class.crackMessage(hwnd, uMsg, wParam, lParam) handlers.each { |handler| (handler.arity == 0) ? handler.call : handler.call(args) result = args[:result] } end result end |