Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Compatibility with old programs
Message
De
15/03/2001 15:38:11
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
 
 
À
15/03/2001 07:17:25
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00485229
Message ID:
00485581
Vues:
12
>>I make the method and I add the commands in command1.click
>>But when I press INS VPF returns an error :
>>Thisform can only be used within a method
>>Some mistake ? I do wrong something ?
>>Thanks
>Ah... I guess you can't do thisform from within a on key label - I have never tried it.
>
>I suppose you could do
>
>
On key label Ins _screen.activeform.Insert()
>
>But it's not the best way to reference the current form by all accounts.
>
>The other thing you could do is call a procedure/prg which finds the currently active form and runs it's insert method if it has one
>
>
On key label Ins DO FormClick.prg with 'Insert'
The whole story pretty much explains why it is not recommendable to rely on calling form-related stuff from an OKL or menu - the code invoked this way executes in a different environment. It knows nothing about your form, it has to find it if necessary; it can't use any of "this." "thisform." stuff because it doesn't belong to the form; it's somewhere outside. I'm not even sure which datasession does it see - form's own or the default one, and does that depend on where the mouse is (just watch Set("Datasession") in the debugger in one window, and hover the mouse over an active form).

The preferred method is to keep all the form-related thing in the form (that's what encapsulation is for, right?). Catching keypresses should go to form's keypressed method (remember to set form.keypreview=.t. so the form's keypress will fire before the control's one). I don't know what's the keycode for insert and delete (delete should be something like 8 or equal to ctrl-h, maybe), they are all listed in the help under inkey(). So the form.keypress should look like this:
lparameters nkeycode, nshiftaltctrl
do case
   case... [handle any other special cases here]
   case nKeyCode=[code for Delete comes here]
      thisform.deleterecord()
      nodefault
   case nKeyCode=[code for insert comes here]
      thisform.insertrecord()
      nodefault
endcase

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform