Module: Fzeet::ShellFileDialogMethods

Included in:
ShellFileOpenDialog, ShellFileSaveDialog, ShellFolderDialog
Defined in:
lib/fzeet/windows/comdlg/ShellFileDialog.rb

Instance Method Summary collapse

Instance Method Details

#itemObject



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/fzeet/windows/comdlg/ShellFileDialog.rb', line 32

def item
	FFI::MemoryPointer.new(:pointer) { |psi|
		next unless GetResult(psi) == Windows::S_OK

		si = Windows::ShellItem.new(psi.read_pointer)

		begin
			yield si
		ensure
			si.Release
		end
	}
end

#itemsObject



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/fzeet/windows/comdlg/ShellFileDialog.rb', line 46

def items
	FFI::MemoryPointer.new(:pointer) { |psia|
		next unless GetResults(psia) == Windows::S_OK

		sia = Windows::ShellItemArray.new(psia.read_pointer)

		begin
			yield sia
		ensure
			sia.Release
		end
	}
end

#pathObject



60
# File 'lib/fzeet/windows/comdlg/ShellFileDialog.rb', line 60

def path; item { |si| return si.path } end

#pathsObject



62
# File 'lib/fzeet/windows/comdlg/ShellFileDialog.rb', line 62

def paths; items { |sia| return sia.map(&:path) } end

#Show(*args) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/fzeet/windows/comdlg/ShellFileDialog.rb', line 24

def Show(*args)
	raise "#{self}.#{__method__} failed." if
		Windows.FAILED(result = vtbl[:Show].call(self, *args)) &&
		result != Windows.HRESULT_FROM_WIN32(Windows::ERROR_CANCELLED) - 0x1_0000_0000

	result
end

#show(window = Application.window) ⇒ Object



64
65
66
# File 'lib/fzeet/windows/comdlg/ShellFileDialog.rb', line 64

def show(window = Application.window)
	DialogResult.new((Show(window.handle) == Windows::S_OK) ? Windows::IDOK : Windows::IDCANCEL)
end