Class: Fzeet::FolderDialog
- Inherits:
-
CommonDialog
- Object
- CommonDialog
- Fzeet::FolderDialog
- Defined in:
- lib/fzeet/windows/comdlg/FileDialog.rb
Constant Summary collapse
- DialogStruct =
Windows::BROWSEINFO
- HookProc =
-> *args { CommonDialog::HookProc.(*args.unshift(DialogStruct)) }
Constants included from WindowMethods
Instance Attribute Summary
Attributes inherited from CommonDialog
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ FolderDialog
constructor
A new instance of FolderDialog.
- #path ⇒ Object
- #show(window = Application.window) ⇒ 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, #size, #size=, #style, #style?, #text, #text=, #textlen, #topmost=, #topmost?, #update, #visible=, #visible?, #xstyle, #xstyle?
Methods included from Toggle
Constructor Details
#initialize(opts = {}) ⇒ FolderDialog
Returns a new instance of FolderDialog.
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/fzeet/windows/comdlg/FileDialog.rb', line 198 def initialize(opts = {}) _opts = { root: nil, displayName: nil, title: nil, flags: 0, hook: nil, param: 0, image: 0 } badopts = opts.keys - _opts.keys; raise "Bad option(s): #{badopts.join(', ')}." unless badopts.empty? _opts.merge!(opts) @struct = DialogStruct.new @struct[:ulFlags] = Fzeet.flags([:returnonlyfsdirs, :usenewui], :bif_) @struct[:lpfn] = HookProc @struct[:lParam] = object_id super() end |
Instance Method Details
#path ⇒ Object
220 |
# File 'lib/fzeet/windows/comdlg/FileDialog.rb', line 220 def path; @path && @path.dup end |
#show(window = Application.window) ⇒ Object
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/fzeet/windows/comdlg/FileDialog.rb', line 222 def show(window = Application.window) @struct[:hwndOwner] = window.handle @path = nil DialogResult.new(((pidl = Windows.SHBrowseForFolder(@struct)).null?) ? Windows::IDCANCEL : Windows::IDOK).tap { |result| next unless result.ok? FFI::MemoryPointer.new(:char, 4096) { |p| Windows.SHGetPathFromIDList(pidl, p) @path = p.read_string } } ensure Windows.CoTaskMemFree(pidl) end |