Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Execute code before closing form
Message
 
 
À
28/03/2007 15:11:18
Hans-Otto Lochmann
Dr. Lochmann Consulting Gmbh
Frankfurt, Allemagne
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
01209324
Message ID:
01209383
Vues:
24
Hans,

I'm sorry, but two problems caught my eye in this code:

1) In Keypress Dodefault() we need to pass parameters.

2) You may want to avoid repeating the same code in Release and QueryUnload. It could be a different method or close button should check for QueryUnload.


>>Hi all,
>>
>>Before exiting a VFP form, I need some code to execute, to update certain parameters through the command 'thisform.cmdUpdate.click'. Could anyone tell me how this is triggered a VFP form? (Which event, and how)
>>
>>Thanks in advance.
>>
>>Regards,
>>
>>Steve
>
>Hi Steven,
>
>how about this:
>
>
>**************************************************
>oForm = Createobject('frmBase')
>oForm.Show(1)
>
>Define Class frmbase As Form
>
>  Caption = "FormBase"
>  KeyPreview = .T.
>  *-- Reflects the answer to the questions, whether the user wants to close the form.
>  lreleaseapproved = .F.
>  Name = "frmbase"
>
>  Add Object cmdexit As CommandButton With ;
>    Top = 120, ;
>    Left = 190, ;
>    Height = 27, ;
>    Width = 84, ;
>    Caption = "E\<xit", ;
>    Name = "cmdExit"
>
>  Procedure KeyPress
>    Lparameters nKeyCode, nShiftAltCtrl
>    If nKeyCode = 27 And nShiftAltCtrl = 0
>      Nodefault
>      Thisform.Release
>    Endif
>    DoDefault()
>  Endproc
>
>  Procedure Init
>    If !DoDefault()
>      Return .F.
>    Endif
>    With Thisform
>      .lreleaseapproved = .F.
>      .AutoCenter = .T.
>      .AutoCenter = .F.
>    Endwith
>  Endproc
>
>  Procedure OnClose
>    Messagebox('Do some useful code here!')
>  Endproc
>
>  Procedure QueryUnload
>    Local lnAnswer As Integer
>    With This As Thisform
>      If .lreleaseapproved = .F.
>        m.lnAnswer = Messagebox( ;
>          'Would you really like to close down?', ;
>          4+32+256+4096, .Caption)
>        If m.lnAnswer = 6
>          .lreleaseapproved = .T.
>          .OnClose()
>          DoDefault()
>        Else
>          .lreleaseapproved = .F.
>          Nodefault
>        Endif m.lnAnswer = 6
>      Else
>        DoDefault()
>      Endif .lreleaseapproved = .F.
>    Endwith
>    Return
>  Endproc
>
>  Procedure Release
>    Local lnAnswer As Integer
>    With This As Thisform
>      If .lreleaseapproved = .F.
>        m.lnAnswer = Messagebox( ;
>          'Would you really like to close down?', ;
>          4+32+256+4096, .Caption)
>        If m.lnAnswer = 6
>          .lreleaseapproved = .T.
>          .OnClose()
>          DoDefault()
>        Else
>          .lreleaseapproved = .F.
>          Nodefault
>        Endif m.lnAnswer = 6
>      Else
>        DoDefault()
>      Endif .lreleaseapproved = .F.
>    Endwith
>    Return
>  Endproc
>
>  Procedure Unload
>    Nodefault
>    *--- Do whatever needed at the very end like CLEAR EVENTS
>    DoDefault()
>  Endproc
>
>  Procedure cmdexit.Click
>    Thisform.Release()
>  Endproc
>
>Enddefine
>**************************************************
>
>
>works with all three: button click, close box click (top right) and ESC.
>
>Hans
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform