Class: Fzeet::FileDialog

Inherits:
CommonDialog show all
Defined in:
lib/fzeet/windows/comdlg/FileDialog.rb

Direct Known Subclasses

FileOpenDialog, FileSaveDialog

Constant Summary collapse

DialogStruct =
Windows::OPENFILENAME
HookProc =
-> *args { CommonDialog::HookProc.(*args.unshift(DialogStruct)) }

Constants included from WindowMethods

WindowMethods::EnumChildProc

Instance Attribute Summary

Attributes inherited from CommonDialog

#struct

Instance Method Summary collapse

Methods inherited from CommonDialog

crackMessage, #hookProc, #on

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

#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

#disposeObject



151
# File 'lib/fzeet/windows/comdlg/FileDialog.rb', line 151

def dispose; @buf.free end

#pathObject



153
# File 'lib/fzeet/windows/comdlg/FileDialog.rb', line 153

def path; @buf.read_string end