Class: Fzeet::FolderDialog
Constant Summary
collapse
- DialogStruct =
Windows::BROWSEINFO
- HookProc =
-> *args { CommonDialog::HookProc.(*args.unshift(DialogStruct)) }
WindowMethods::EnumChildProc
Instance Attribute Summary
Attributes inherited from CommonDialog
#struct
Instance Method Summary
collapse
crackMessage, #hookProc, #on
#[], #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
#toggle
Constructor Details
#initialize(opts = {}) ⇒ FolderDialog
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
|
# File 'lib/fzeet/windows/comdlg/FileDialog.rb', line 217
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
239
|
# File 'lib/fzeet/windows/comdlg/FileDialog.rb', line 239
def path; @path && @path.dup end
|
#show(window = Application.window) ⇒ Object
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
# File 'lib/fzeet/windows/comdlg/FileDialog.rb', line 241
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
|