Module: Fzeet::WindowMethods
Defined Under Namespace
Classes: ExStyle, Long, Style
Constant Summary
collapse
- EnumChildProc =
FFI::Function.new(:int, [:pointer, :long], convention: :stdcall) { |hwnd, lParam|
ObjectSpace._id2ref(lParam).call(Handle.instance(hwnd)) if Handle.instance?(hwnd); 1
}
Instance Method Summary
collapse
Methods included from Toggle
#toggle
Instance Method Details
#[](id) ⇒ Object
196
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 196
def [](id) Handle.instance(Windows.DetonateLastError(FFI::Pointer::NULL, :GetDlgItem, @handle, Command[id])) end
|
#capture=(capture) ⇒ Object
162
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 162
def capture=(capture) (capture) ? Windows.SetCapture(@handle) : Windows.DetonateLastError(0, :ReleaseCapture) end
|
#capture? ⇒ Boolean
161
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 161
def capture?; Windows.GetCapture().to_i == @handle.to_i end
|
#dialog=(dialog) ⇒ Object
43
44
45
46
47
48
49
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 43
def dialog=(dialog)
if dialog
Application.dialogs << self unless dialog?
else
Application.dialogs.delete(self)
end
end
|
#dialog? ⇒ Boolean
41
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 41
def dialog?; Application.dialogs.include?(self) end
|
#dlgmsg?(msg) ⇒ Boolean
51
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 51
def dlgmsg?(msg) Windows.IsDialogMessage(@handle, msg) != 0 end
|
194
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 194
def ; Windows.DetonateLastError(0, :DrawMenuBar, @handle); self end
|
#eachChild(&block) ⇒ Object
202
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 202
def eachChild(&block) Windows.EnumChildWindows(@handle, EnumChildProc, block.object_id); self end
|
#enabled=(enabled) ⇒ Object
111
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 111
def enabled=(enabled) Windows.EnableWindow(@handle, (enabled) ? 1 : 0) end
|
#enabled? ⇒ Boolean
110
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 110
def enabled?; Windows.IsWindowEnabled(@handle) != 0 end
|
#focus=(focus) ⇒ Object
121
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 121
def focus=(focus) Windows.DetonateLastError(FFI::Pointer::NULL, :SetFocus, (focus) ? @handle : nil) end
|
#focus? ⇒ Boolean
120
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 120
def focus?; Windows.GetFocus().to_i == @handle.to_i end
|
#invalidate(rect = rect, erase = 1) ⇒ Object
184
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 184
def invalidate(rect = rect, erase = 1) Windows.DetonateLastError(0, :InvalidateRect, @handle, rect, erase); self end
|
#location ⇒ Object
144
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 144
def location; position.lt end
|
#location=(a) ⇒ Object
145
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 145
def location=(a) Windows.DetonateLastError(0, :SetWindowPos, @handle, nil, a[0], a[1], 0, 0, Fzeet.flags([:nosize, :nozorder], :swp_)) end
|
#long ⇒ Object
73
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 73
def long; Long.new(self) end
|
186
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 186
def ; (Handle.instance?(handle = Windows.GetMenu(@handle))) ? Handle.instance(handle) : nil end
|
188
189
190
191
192
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 188
def ()
self..dispose if self.
Windows.DetonateLastError(0, :SetMenu, @handle, .handle) if
end
|
#message(message, opts = {}) ⇒ Object
7
8
9
10
11
12
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 7
def message(message, opts = {})
opts[:window] ||= self
opts[:caption] ||= text
Fzeet.message(message, opts)
end
|
#paint ⇒ Object
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 164
def paint
hdc = Windows.DetonateLastError(FFI::Pointer::NULL, :BeginPaint, @handle, ps = Windows::PAINTSTRUCT.new)
begin
dc = Handle.wrap(hdc, DCMethods)
dc.instance_variable_set(:@window, self)
class << dc
attr_reader :window
end
yield dc, ps
ensure
Windows.EndPaint(@handle, ps)
end
self
end
|
#position ⇒ Object
141
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 141
def position; Windows.DetonateLastError(0, :GetWindowRect, @handle, r = Rect.new); r end
|
#position=(a) ⇒ Object
142
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 142
def position=(a) Windows.DetonateLastError(0, :SetWindowPos, @handle, nil, a[0], a[1], a[2], a[3], Fzeet.constant(:nozorder, :swp_)) end
|
#postmsg(msg, wParam = 0, lParam = 0) ⇒ Object
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 30
def postmsg(msg, wParam = 0, lParam = 0)
Windows.DetonateLastError(0, :PostMessage,
@handle,
Fzeet.constant(msg, *self.class::Prefix[:message]),
wParam.to_i,
((lparam = lParam.to_i) > 0x7fff_ffff) ? lparam - 0x1_0000_0000 : lparam
)
self
end
|
#question(message, opts = {}) ⇒ Object
14
15
16
17
18
19
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 14
def question(message, opts = {})
opts[:window] ||= self
opts[:caption] ||= text
Fzeet.question(message, opts)
end
|
#rect ⇒ Object
139
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 139
def rect; Windows.DetonateLastError(0, :GetClientRect, @handle, r = Rect.new); r end
|
#reframe ⇒ Object
150
151
152
153
154
155
156
157
158
159
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 150
def reframe
Windows.DetonateLastError(0, :SetWindowPos,
@handle,
nil,
0, 0, 0, 0,
Fzeet.flags([:nomove, :nosize, :nozorder, :framechanged], :swp_)
)
self
end
|
#sendmsg(msg, wParam = 0, lParam = 0) ⇒ Object
21
22
23
24
25
26
27
28
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 21
def sendmsg(msg, wParam = 0, lParam = 0)
Windows.SendMessage(
@handle,
Fzeet.constant(msg, *self.class::Prefix[:message]),
wParam.to_i,
((lparam = lParam.to_i) > 0x7fff_ffff) ? lparam - 0x1_0000_0000 : lparam
)
end
|
#show(cmdShow = :shownormal) ⇒ Object
116
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 116
def show(cmdShow = :shownormal) Windows.ShowWindow(@handle, Fzeet.constant(cmdShow, :sw_)); self end
|
#size ⇒ Object
147
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 147
def size; r = position; Size[r[:right] - r[:left], r[:bottom] - r[:top]] end
|
#size=(a) ⇒ Object
148
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 148
def size=(a) Windows.DetonateLastError(0, :SetWindowPos, @handle, nil, 0, 0, a[0], a[1], Fzeet.flags([:nomove, :nozorder], :swp_)) end
|
#style ⇒ Object
94
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 94
def style; Style.new(self) end
|
#style?(style) ⇒ Boolean
93
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 93
def style?(style) (long[:style] & (style = Fzeet.constant(style, *self.class::Prefix[:style]))) == style end
|
#text ⇒ Object
125
126
127
128
129
130
131
132
133
134
135
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 125
def text
return '' if (len = textlen + 1) == 1
''.tap { |text|
FFI::MemoryPointer.new(:char, len) { |buf|
Windows.DetonateLastError(0, :GetWindowText, @handle, buf, len)
text << buf.read_string
}
}
end
|
#text=(text) ⇒ Object
137
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 137
def text=(text) Windows.DetonateLastError(0, :SetWindowText, @handle, text.to_s) end
|
#textlen ⇒ Object
123
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 123
def textlen; Windows.GetWindowTextLength(@handle) end
|
#topmost=(topmost) ⇒ Object
#topmost? ⇒ Boolean
99
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 99
def topmost?; xstyle?(:topmost) end
|
#update ⇒ Object
118
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 118
def update; Windows.DetonateLastError(0, :UpdateWindow, @handle); self end
|
#visible=(visible) ⇒ Object
#visible? ⇒ Boolean
113
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 113
def visible?; Windows.IsWindowVisible(@handle) != 0 end
|
#xstyle ⇒ Object
97
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 97
def xstyle; ExStyle.new(self) end
|
#xstyle?(xstyle) ⇒ Boolean
96
|
# File 'lib/fzeet/windows/user/Window/WindowMethods.rb', line 96
def xstyle?(xstyle) (long[:exstyle] & (xstyle = Fzeet.constant(xstyle, *self.class::Prefix[:xstyle]))) == xstyle end
|