module Mouse Point = Struct.new(:x, :y) if !const_defined?(:Point) Message = Struct.new(:message, :wparam, :lparam, :pt) if !const_defined?(:Message) Param = Struct.new(:x, :y, :scroll) if !const_defined?(:Param) Scroll = 0x0000020A if !const_defined?(:Scroll) Get_Message = Win32API.new('user32', 'GetMessage', 'plll', 'l') if !const_defined?(:Get_Message) module_function def hiword(dword) return((dword & 0xffff0000) >> 16) & 0x0000ffff end def loword(dword) return dword & 0x0000ffff end def word2signed_short(value) return value if (value & 0x8000) == 0 return -1 *((~value & 0x7fff) + 1) end def unpack_dword(buffer, offset = 0) bitso = buffer.bytes.to_a ret = bitso[offset + 0] & 0x000000ff ret |=(bitso[offset + 1] << (8 * 1)) & 0x0000ff00 ret |=(bitso[offset + 2] << (8 * 2)) & 0x00ff0000 ret |=(bitso[offset + 3] << (8 * 3)) & 0xff000000 return ret end def unpack_msg(buffer) msg = Message.new msg.pt = Point.new msg.message = unpack_dword(buffer,4 * 1) msg.wparam = unpack_dword(buffer, 4 * 2) msg.lparam = unpack_dword(buffer,4 * 3) msg.pt.x = unpack_dword(buffer, 4 * 5) msg.pt.y = unpack_dword(buffer, 4 * 6) return msg end def wmcallback(msg) return unless msg.message == Scroll param = Param.new param.x = word2signed_short(loword(msg.lparam)) param.y = word2signed_short(hiword(msg.lparam)) param.scroll = word2signed_short(hiword(msg.wparam)) return [param.x, param.y, param.scroll] end def scroll msg = "\0" * 32 Get_Message.call(msg, @handle || @hwnd || 0, 0, 0) r = wmcallback(unpack_msg(msg)) return r if !r.nil? end end class Window_Selectable alias jet1085_update update def update(*args, &block) update_scroll if self.active && self.visible jet1085_update(*args, &block) end def update_scroll if true#Jet::MouseSystem::USE_WHEEL_DETECTION f = Mouse.scroll if !f.nil? if f[2] < 0 if contents.height > self.height && self.oy - contents.height < -self.height + 32 self.top_row = self.top_row + 1 end else self.top_row = self.top_row - 1 if contents.height > self.height end end end end end