Module: Fzeet::HeaderMethods

Included in:
Header
Defined in:
lib/fzeet/windows/comctl/Header.rb

Constant Summary collapse

Prefix =
{
  xstyle: [:ws_ex_],
  style: [:hds_, :ws_],
  message: [:hdm_, :ccm_, :wm_],
  notification: [:hdn_, :nm_]
}

Instance Method Summary collapse

Instance Method Details

#countObject



156
# File 'lib/fzeet/windows/comctl/Header.rb', line 156

def count; sendmsg(:getitemcount) end

#insertItem(i, text, width) ⇒ Object



158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/fzeet/windows/comctl/Header.rb', line 158

def insertItem(i, text, width)
  hdi = Windows::HDITEM.new

  hdi[:mask] = Fzeet.flags([:width, :text, :format, :order], :hdi_)
  hdi[:cxy] = width
  hdi[:pszText] = ptext = FFI::MemoryPointer.from_string(text)
  hdi[:fmt] = Fzeet.flags([:left, :string], :hdf_)
  hdi[:iOrder] = i

  sendmsg(:insertitem, 0, hdi.pointer)

  self
ensure
  ptext.free
end

#modifyItem(i, text, style = 0) ⇒ Object



174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/fzeet/windows/comctl/Header.rb', line 174

def modifyItem(i, text, style = 0)
  hdi = Windows::HDITEM.new

  hdi[:mask] = Fzeet.flags([:text, :format], :hdi_)
  hdi[:pszText] = ptext = FFI::MemoryPointer.from_string(text)
  hdi[:fmt] = Fzeet.flags([:left, :string], :hdf_)
  hdi[:fmt] |= Fzeet.flags([*style].compact, :hdf_)

  sendmsg(:setitem, i, hdi.pointer)

  self
ensure
  ptext.free
end