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.



237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
# File 'lib/fzeet/windows/comctl/PropertySheet.rb', line 237

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