Class: Fzeet::PropertySheet

Inherits:
Object
  • Object
show all
Defined in:
lib/fzeet/windows/comctl/PropertySheet.rb

Instance Method Summary collapse

Constructor Details

#initialize(parent, opts = {wizard: false}) ⇒ PropertySheet

Returns a new instance of PropertySheet.



218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/fzeet/windows/comctl/PropertySheet.rb', line 218

def initialize(parent, opts = {wizard: false})
	pointers = []

	psps = PropertyPage::PROPSHEETPAGEA1.new

	dt = Windows::DLGTEMPLATE.new

	dt[:style] = Fzeet.flags([:'3dlook', :control, :child, :tabstop], :ds_, :ws_)
	dt[:x], dt[:y], dt[:cx], dt[:cy] = 100, 100, 300, 150

	psp = psps[:array][0]

	psp[:dwSize] = psp.size
	psp[:dwFlags] = Fzeet.flags([:dlgindirect, :usetitle], :psp_)
	psp[:hInstance] = Windows.GetModuleHandle(nil)
	psp[:template][:pResource] = dt
	psp[:pszTitle] = pointers.push(FFI::MemoryPointer.from_string("Page")).last

	psh = Windows::PROPSHEETHEADER.new

	psh[:dwSize] = psh.size
	psh[:dwFlags] = Fzeet.flags(:propsheetpage, :psh_)
	psh[:dwFlags] |= Windows::PSH_WIZARD if opts[:wizard]
	psh[:hwndParent] = parent.handle
	psh[:hInstance] = Windows.GetModuleHandle(nil)
	psh[:pszCaption] = pointers.push(FFI::MemoryPointer.from_string('Sheet')).last
	psh[:nPages] = 1
	psh[:start][:nStartPage] = 0
	psh[:pages][:ppsp] = psps

	Windows.DetonateLastError(-1, :PropertySheet, psh)
ensure
	pointers.each(&:free)
end