Class: Fzeet::FileDialog
- Inherits:
-
CommonDialog
- Object
- CommonDialog
- Fzeet::FileDialog
- Defined in:
- lib/fzeet/windows/comdlg/FileDialog.rb
Direct Known Subclasses
Constant Summary collapse
- DialogStruct =
Windows::OPENFILENAME
- HookProc =
-> *args { CommonDialog::HookProc.(*args.unshift(DialogStruct)) }
Constants included from WindowMethods
Instance Attribute Summary
Attributes inherited from CommonDialog
Instance Method Summary collapse
- #dispose ⇒ Object
-
#initialize(opts = {}) ⇒ FileDialog
constructor
A new instance of FileDialog.
- #path ⇒ Object
Methods inherited from CommonDialog
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
Constructor Details
#initialize(opts = {}) ⇒ FileDialog
Returns a new instance of FileDialog.
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/fzeet/windows/comdlg/FileDialog.rb', line 113 def initialize(opts = {}) _opts = { filter: nil, customFilter: nil, filterIndex: 0, fileTitle: nil, initialDir: nil, title: nil, flags: 0, fileExtension: nil, defExt: nil, custData: 0, hook: nil, templateName: nil, xflags: 0 } badopts = opts.keys - _opts.keys; raise "Bad option(s): #{badopts.join(', ')}." unless badopts.empty? _opts.merge!(opts) @struct = DialogStruct.new @struct[:lStructSize] = @struct.size @struct[:hInstance] = Windows.GetModuleHandle(nil) @struct[:lpstrFile] = @buf = FFI::MemoryPointer.new(:char, 4096) @struct[:nMaxFile] = @buf.size @struct[:Flags] = Fzeet.flags([:enablehook, :explorer, :enablesizing, :overwriteprompt] + [*_opts[:flags]], :ofn_) @struct[:lCustData] = object_id @struct[:lpfnHook] = HookProc super() begin yield self ensure dispose end if block_given? end |
Instance Method Details
#dispose ⇒ Object
151 |
# File 'lib/fzeet/windows/comdlg/FileDialog.rb', line 151 def dispose; @buf.free end |
#path ⇒ Object
153 |
# File 'lib/fzeet/windows/comdlg/FileDialog.rb', line 153 def path; @buf.read_string end |