Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Class definition problem
Message
De
29/05/2001 23:57:10
Jimi Lee
Pop Electronic Products Ltd.
Hong Kong, Hong Kong
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Titre:
Class definition problem
Divers
Thread ID:
00512512
Message ID:
00512512
Vues:
49
hi all,

I'm gonna create an container object on a form and place a shape on it, where it can detect mouse click and do some stuff. The following code works fine:
do form main
for i=1 to 5  && to put 5 object on the form, named Room1 to Room5
  main.addobject("Room"+alltrim(str(i)), "MyRoom")
endfor

define class MyRoom as container
  add object "Detector" as MyShape

  procedure Detector.click
    wait window "You clicked me!"
  endproc
enddefine

define class MyShape as shape
  procedure init
    with this
      .borderstyle=0
      .backstyle=0
    endwith
  endproc
enddefine
But I want to pass parameter to the MyShape object such that I can do different motion when user click on different MyRoom object.

So I changed the MyRoom class as following, but it says "unknown member DEDECTOR" at the line "procedure Detector.click"
define class MyRoom as container
  procedure Init
    this.addobject("Detector", "MyShape")
  endproc

  procedure Detector.click
    wait window "You clicked me!"
  endproc
enddefine

define class MyShape as shape
  procedure init
    with this
      .borderstyle=0
      .backstyle=0
    endwith
  endproc
enddefine
I also tried this code but it says "unknown member THIS"
define class MyRoom as container
  add object "Detector" as MyShape
enddefine

define class MyShape as shape
  procedure init
    with this
      .borderstyle=0
      .backstyle=0
    endwith
  endproc

  procedure this.click
    wait window "You clicked me!"
  endproc
enddefine
So only the first set of code works, the other two not. What's wrong with them? No matter how, I only want to pass paramter to the class definitin such that I can determine which shape is clicked, any help please?

Thanks in advance!
error(503): file structure failure, signature file corrupted.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform