class Fzeet::WindowClass
Attributes
name[R]
prototype[R]
Public Class Methods
new(prototype, name, opts = {})
click to toggle source
# File lib/fzeet/windows/user/Window/Common.rb, line 484 def initialize(prototype, name, opts = {}) @prototype = prototype @name = name className = FFI::MemoryPointer.from_string(@name) _opts = { style: [], wndProc: BasicWindow::WindowProc, clsExtra: 0, wndExtra: 0, icon: SystemIcon.new(:application), cursor: SystemCursor.new(:arrow), background: SystemBrush.new(:window), iconSm: nil } badopts = opts.keys - _opts.keys; raise "Bad option(s): #{badopts.join(', ')}." unless badopts.empty? self[:cbSize] = Windows::WNDCLASSEX.size self[:hInstance] = Windows.GetModuleHandle(nil) self[:lpszClassName] = className if @prototype self[:style] = Fzeet.flags(opts[:style] || [], :cs_) | @prototype[:style] self[:lpfnWndProc] = opts[:wndProc] || @prototype[:lpfnWndProc] self[:cbClsExtra] = (opts[:clsExtra] || 0) + @prototype[:cbClsExtra] self[:cbWndExtra] = (opts[:wndExtra] || 0) + @prototype[:cbWndExtra] self[:hIcon] = (opts[:icon] && opts[:icon].handle) || @prototype[:hIcon] self[:hCursor] = (opts[:cursor] && opts[:cursor].handle) || @prototype[:hCursor] self[:hbrBackground] = (opts[:background] && opts[:background].handle) || @prototype[:hbrBackground] self[:hIconSm] = (opts[:iconSm] && _opts[:iconSm].handle) || @prototype[:hIconSm] else _opts.merge(opts) self[:style] = Fzeet.flags(_opts[:style], :cs_) self[:lpfnWndProc] = _opts[:wndProc] self[:cbClsExtra] = _opts[:clsExtra] self[:cbWndExtra] = _opts[:wndExtra] self[:hIcon] = _opts[:icon].handle self[:hCursor] = _opts[:cursor].handle self[:hbrBackground] = _opts[:background].handle self[:hIconSm] = _opts[:iconSm] && _opts[:iconSm].handle end Windows.DetonateLastError(0, :RegisterClassEx, self) { className.free } end