get event type?

Discussion in 'Questions (Windows Mobile)' started by Byak@, Mar 19, 2009.

  1. Byak@

    Byak@ Active Member Licensed User

    Code:
    sub appstart
    addevent(
    "button1","Click","ev")
    addevent(
    "form1","MouseUp","ev")
    addevent(
    "timer1","Tick","ev")
    end sub

    sub  ev

    end sub
    when "ev" called i may get name of control with keyword SENDER but how can i get what EVENT called this sub?
     
  2. Mr_Gee

    Mr_Gee Active Member Licensed User

    untill it someone has a better solution would this help?
    Code:
    sub appstart
    addevent(
    "button1",Click,"ev1")
    addevent(
    "form1",MouseUp,"ev2")
    addevent(
    "timer1",Tick  ,"ev3")
    end sub

    sub  ev1
        ev(
    "Button")    
    end sub
    sub  ev2
        ev(
    "MouseUp")
    end sub
    sub  ev3
        ev(
    "Tick")
    end sub

    sub  ev(showtype)
        
    MsgBox("Type " & showtype)
    end sub
     
  3. Byak@

    Byak@ Active Member Licensed User

    no,you dont understand me=)
    for example i have 100 controls...and i must add 100 subs?

    but this problem i have?when i create plugins for my program with Scripting dll
    plugins can arr objects to program but now i want add events for this objects,and code of this events in plugin.

    my first example shows exactly the problem
     
  4. agraham

    agraham Expert Licensed User

    No. Just have one event Sub for each type of event then you know the Event type and can use Sender for the source of the event.

    Code:
    sub appstart
      addevent(
    "button1","Click","clickev")
      addevent(
    "form1","MouseUp","mupev")
      addevent(
    "timer1","Tick","tickev")
    end sub

    sub  clickev
      ...
    end sub

    sub  mupev
      ...
    end sub

    sub  tickev
      ...
    end sub
     
  5. Byak@

    Byak@ Active Member Licensed User

    i think about it,but in program used all(maybe not all but many) controls and objects from any dlls and i must create very many subs includes all events...
    it is not good too...
    and most importantly it is unnecessary, it may be sufficient to know what event

    maybe it's real with door dll and object "event"?
     
  6. agraham

    agraham Expert Licensed User

    No, it is not possible. It would need a modification to Basic4ppc to save the event name as well as the sender name. Presently the event name is lost once the event sub has been identified by the Basic4ppc event code.

    Surely there are not that many events you need, and surely it is better to have small individual event Subs handling each type of event rather than one huge Sub with lots of conditional tests inside it trying to handle all the possible event types!

    EDIT:- Remember that you don't need a different event sub for each control or object, only different ones for each individual event name. You can hide them in a module!
     
    Last edited: Mar 19, 2009
  7. Byak@

    Byak@ Active Member Licensed User

    thanks you agraham. it is not good but it better then nothing
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    Also notice that the event sub must match the number of arguments. So the event sub of a MouseUp event should have two parameters (and you can't use the same sub for the Click event).
     
  9. Byak@

    Byak@ Active Member Licensed User

    thanks erel, but it was example and in my app some events not been used(mouseup,mousedown,mousemove,keypress).
    but what you say about add new keyword in basic in latest version? =)
     
  10. Erel

    Erel Administrator Staff Member Licensed User

    I will consider it.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice