class Fzeet::FindReplaceDialog
Constants
- DialogStruct
- HookProc
- Message
Public Class Methods
new(opts = {})
click to toggle source
Calls superclass method
Fzeet::CommonDialog::new
# File lib/fzeet/windows/comdlg/FindReplaceDialog.rb, line 77 def initialize(opts = {}) _opts = { } badopts = opts.keys - _opts.keys; raise "Bad option(s): #{badopts.join(', ')}." unless badopts.empty? _opts.merge!(opts) @frNotifies = {} @struct = DialogStruct.new @struct[:lStructSize] = @struct.size @struct[:hInstance] = Windows.GetModuleHandle(nil) @struct[:Flags] = Fzeet.flags(:enablehook, :fr_) @struct[:lpstrFindWhat] = @findbuf = FFI::MemoryPointer.new(:char, 4096) @struct[:lpstrReplaceWith] = @replacebuf = FFI::MemoryPointer.new(:char, 4096) @struct[:wFindWhatLen] = @findbuf.size @struct[:wReplaceWithLen] = @replacebuf.size @struct[:lCustData] = object_id @struct[:lpfnHook] = HookProc super() end
Public Instance Methods
dispose()
click to toggle source
# File lib/fzeet/windows/comdlg/FindReplaceDialog.rb, line 101 def dispose; [@findbuf, @replacebuf].each(&:free) end
findWhat()
click to toggle source
# File lib/fzeet/windows/comdlg/FindReplaceDialog.rb, line 103 def findWhat; @findbuf.read_string end
frProc(args)
click to toggle source
# File lib/fzeet/windows/comdlg/FindReplaceDialog.rb, line 106 def frProc(args) return unless args[:lParam] == @struct.pointer.address (handlers = @frNotifies[:all]) and handlers.each { |handler| (handler.arity == 0) ? handler.call : handler.call(args) } if @struct[:Flags] & Windows::FR_DIALOGTERM != 0 (handlers = @frNotifies[Windows::FR_DIALOGTERM]) and handlers.each { |handler| (handler.arity == 0) ? handler.call : handler.call(args) } self.dialog = false dispose elsif @struct[:Flags] & Windows::FR_FINDNEXT != 0 (handlers = @frNotifies[Windows::FR_FINDNEXT]) and handlers.each { |handler| (handler.arity == 0) ? handler.call : handler.call(args) } elsif @struct[:Flags] & Windows::FR_REPLACE != 0 (handlers = @frNotifies[Windows::FR_REPLACE]) and handlers.each { |handler| (handler.arity == 0) ? handler.call : handler.call(args) } elsif @struct[:Flags] & Windows::FR_REPLACEALL != 0 (handlers = @frNotifies[Windows::FR_REPLACEALL]) and handlers.each { |handler| (handler.arity == 0) ? handler.call : handler.call(args) } end end
onNotify(notification, &block)
click to toggle source
# File lib/fzeet/windows/comdlg/FindReplaceDialog.rb, line 136 def onNotify(notification, &block) notification = Fzeet.constant(notification, :fr_) unless notification.kind_of?(Integer) || notification == :all (@frNotifies[notification] ||= []) << block self end
replaceWith()
click to toggle source
# File lib/fzeet/windows/comdlg/FindReplaceDialog.rb, line 104 def replaceWith; @replacebuf.read_string end