Class: Fzeet::ColorDialog
Constant Summary
collapse
- DialogStruct =
Windows::CHOOSECOLOR
- HookProc =
-> *args { CommonDialog::HookProc.(*args.unshift(DialogStruct)) }
WindowMethods::EnumChildProc
Instance Attribute Summary
Attributes inherited from CommonDialog
#struct
Instance Method Summary
collapse
crackMessage, #hookProc, #on
#[], #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, #size, #size=, #style, #style?, #text, #text=, #textlen, #topmost=, #topmost?, #update, #visible=, #visible?, #xstyle, #xstyle?
Methods included from Toggle
#toggle
Constructor Details
#initialize(opts = {}) ⇒ ColorDialog
Returns a new instance of ColorDialog.
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/fzeet/windows/comdlg/ColorDialog.rb', line 59
def initialize(opts = {})
_opts = {
}
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[:lpCustColors] = @buf = FFI::MemoryPointer.new(:ulong, 16)
@struct[:Flags] = Fzeet.flags(:enablehook, :cc_)
@struct[:lCustData] = object_id
@struct[:lpfnHook] = HookProc
super()
begin
yield self
ensure
dispose
end if block_given?
end
|
Instance Method Details
#color ⇒ Object
92
|
# File 'lib/fzeet/windows/comdlg/ColorDialog.rb', line 92
def color; result = @struct[:rgbResult]; [Windows.GetRValue(result), Windows.GetBValue(result), Windows.GetBValue(result)] end
|
#dispose ⇒ Object
84
|
# File 'lib/fzeet/windows/comdlg/ColorDialog.rb', line 84
def dispose; @buf.free end
|
#show(window = Application.window) ⇒ Object
86
87
88
89
90
|
# File 'lib/fzeet/windows/comdlg/ColorDialog.rb', line 86
def show(window = Application.window)
@struct[:hwndOwner] = window.handle
DialogResult.new((Windows.ChooseColor(@struct) == 0) ? Windows::IDCANCEL : Windows::IDOK)
end
|