Module: VRMessageHandler

Defined Under Namespace

Modules: VRArrayedComponent Classes: SKIP_DEFAULTHANDLER

Constant Summary collapse

PREHANDLERSTR =

VRMessageHandler

This is a module to handle windows messages. If you need to receive windows messages , this module is necessary.

Methods

— acceptEvents(ev_array)

Declares the windows messages to be handled. 
((|ev_array|)) is an array of the handled messages.
This method calls SWin::addEvent for each message.

— addHandler(msg,handlername,argtype,argparsestr)

Defines the name and type of the message handler for ((|msg|)).
The handlername is composed with ((|handlername|)) and the arguments
are depend on ((|argtype|)) which is a constant in module MSGTYPE.
When the message come with structured lParam, it is necessary to be defined
((|argparsestr|)) to devide it.
"self_"

Instance Method Summary collapse

Instance Method Details

#acceptEvents(ev_array) ⇒ Object



244
245
246
247
248
# File 'lib/vr/vruby.rb', line 244

def acceptEvents(ev_array)
  ev_array.each do |ev|
    addEvent ev
  end
end

#addHandler(msg, handlername, handlertype, argparsestr) ⇒ Object



250
251
252
253
254
255
256
# File 'lib/vr/vruby.rb', line 250

def addHandler(msg,handlername,handlertype,argparsestr)
  @_vr_handlers={} unless defined?(@_vr_handlers)
  @_vr_handlers[msg]=[] unless @_vr_handlers[msg]
  @_vr_handlers[msg].push [
       (PREHANDLERSTR+handlername).intern,handlertype,argparsestr
     ]
end

#addNoRelayMessages(arg) ⇒ Object

for VRMessageParentRelayer



234
235
236
237
# File 'lib/vr/vruby.rb', line 234

def addNoRelayMessages(arg)  # for VRMessageParentRelayer
  @_vr_msg_norelays=[] unless defined?(@_vr_msg_norelays)
  @_vr_msg_norelays += arg if arg and  arg.size>0
end

#controlmsg_dispatching(ct, methodname, *args) ⇒ Object



347
348
349
350
351
352
353
354
355
356
357
358
# File 'lib/vr/vruby.rb', line 347

def controlmsg_dispatching(ct,methodname,*args)
  mthdname = "#{ct.name}_#{methodname}"
  if respond_to?(mthdname)
    if ct.is_a?(VRArrayedComponent) then
      send(mthdname,ct._vr_arrayednumber,*args)
    else
      send(mthdname,*args) 
    end
  else
    0
  end
end

#deleteHandler(msg, handlername) ⇒ Object



258
259
260
261
262
263
# File 'lib/vr/vruby.rb', line 258

def deleteHandler(msg,handlername)
  return false unless defined?(@_vr_handlers) and @vr_handlers[msg]
  @_vr_handlers.delete_if do |shandler|
    shandler[0] != (PREHANDLERSTR+handlername).intern
  end
end

#msghandlerinitObject



226
227
228
229
230
231
232
# File 'lib/vr/vruby.rb', line 226

def msghandlerinit
  @_vr_handlers={} unless defined?(@_vr_handlers)
  self.hookwndproc unless self.hookedwndproc?

            # for VRMessageParentRelayer
  @_vr_msg_norelays=[] unless defined?(@_vr_msg_norelays)
end

#selfmsg_dispatching(methodname, *args) ⇒ Object



360
361
362
363
364
365
366
367
# File 'lib/vr/vruby.rb', line 360

def selfmsg_dispatching(methodname,*args)
  smethod="self_#{methodname}".intern
  if respond_to?(smethod) then
    send(smethod,*args) 
  else
    nil
  end
end

#vrinitObject



239
240
241
242
# File 'lib/vr/vruby.rb', line 239

def vrinit
  super
  msghandlerinit
end