ATOUTFOX
COMMUNAUTÉ FRANCOPHONE DES PROFESSIONNELS FOXPRO
Visual FoxPro : le développement durable

Forum AtoutFox : Re: Excel 2007 / vfp petits trucs svp   

Sujet

rss Flux RSS des derniers messages

Vous devez vous identifier pour pouvoir poser une question ou répondre.

mer. 11 décembre 2013, 14h18
AL
France France

atoutfox.public.association

Re: Excel 2007 / vfp petits trucs svp

Bonjour,

je fais ça aussi pour générer des états statistique ou des listes de rapport d'activité dans Excel que les utilisateurs peuvent modifier/éditer APRES la creation et l'enregistrement.

Je part d'un classseur "template" qui contient les onglets, formules, macro qui vont bien dont une macro autoexec.
Pendant le temps du traitement Excel celui-ci est réduit.
A la fin enregistrement du classeur sous un autre nom défini par une variable (nom de base+date AAAAmm) et fermeture du classeur donc Excel reste ouvert pour un autre traitement.

J'utilise aussi dans mon main.prg de Fox un code que m'avais transmit Mike Gagnon qui évite que l'utilsateur re-lance l'exe Fox dans le cas des parkinsoniens du double-clic ou les trop pressés.
Code de Mike Gagnon ci-dessous

Alain:

* EMPECHER PLUSIEURS EXECUTIONS DU MEME EXE SUR LE MEME PC

* Tout le code que je t'ai proposé doit aller dans le main programme.
* Tu mets le IF NOT FirstTime("Run2.exe") et les deux lignes
* suivantes au tout début et le restant à la fin du main mais en fonction
* (je m'excuse si ce n'etait pas clair). Tu dois ajouter une ligne à la fonction
* Mike Gagnon Newsgroup foxpro microsoft / Atoutfox

IF NOT FirstTime("Run2.exe")  && mettre le nom du exe a tester
 QUIT
ENDIF

DO INI_Runtime.prg  && le PRG de lancement de l'application



FUNCTION Firsttime
LPARAMETERS tcAppName
*** This function uses the creation of a named MUTEX to determine whether
*** or not the application is already running. This function should be called
*** near the top of the application's main program to create a named object
*** that can be checked every time the application is started.  If the named
*** object exists, the function will try to activate the FoxPro running application.

LOCAL lcMsg, lnAttributes, lnOwner, lcName, lnMutexHandle, lnhWnd, lnRelationship, lnStyle, llRetVal
LOCAL lcAppName

lcMsg = ''
SET ASSERTS ON
IF EMPTY( NVL( tcAppName, '' ) )
  TEXT TO lcMsg NOSHOW
    This is another Brain Dead Programmer Error.
    You must pass the name of an application to FirstTime().
    Have a nice day now...
  ENDTEXT
  ASSERT .F. MESSAGE lcMsg
  RETURN
ENDIF

lcAppName = UPPER( ALLTRIM( tcAppName ) ) + CHR( 0 )

*** Declare just API functions and constants
#DEFINE SW_MAXIMIZE              3
#DEFINE ERROR_ALREADY_EXISTS   183
#DEFINE GW_HWNDNEXT              2
#DEFINE GW_CHILD                 5

DECLARE INTEGER CreateMutex IN WIN32API INTEGER lnAttributes, INTEGER lnOwner, STRING @lcName
DECLARE INTEGER GetProp IN WIN32API INTEGER lnhWnd, STRING @lcName
DECLARE INTEGER SetProp IN WIN32API INTEGER lnhWnd, STRING @lcNam, INTEGER lnValue
DECLARE INTEGER CloseHandle IN WIN32API INTEGER lnMutexHandle
DECLARE INTEGER GetLastError IN WIN32API
DECLARE INTEGER GetWindow IN USER32 INTEGER lnhWnd, INTEGER lnRelationship
DECLARE INTEGER GetDesktopWindow IN WIN32API
DECLARE BringWindowToTop IN Win32APi INTEGER lnhWnd
DECLARE ShowWindow IN WIN32API INTEGER lnhWnd, INTEGER lnStyle

*** Try and create a new MUTEX with the name of the passed application
 lnMutexHandle = CreateMutex( 0, 1, @lcAppName )

*** If the named MUTEX creation fails because it exists already, try to display
*** the existing application
 IF GetLastError() = ERROR_ALREADY_EXISTS

*** Get the hWnd of the first top level window on the Windows Desktop.
 lnhWnd = GetWindow( GetDesktopWindow(), GW_CHILD )

*** Loop through the windows.
  DO WHILE lnhWnd > 0

   *** Is this the one that we are looking for?
   *** Look for the property we added the first time
   *** we launched the application
     IF GetProp( lnhWnd, @lcAppName ) = 1
* AL
MESSAGEBOX("CE PROGRAMME EST DEJA OUVERT !!!",48," ON FAIT ATTENTION ...",750)
* FIN AL
       *** Activate the app and exit stage left
       BringWindowToTop( lnhWnd )
       ShowWindow( lnhWnd, SW_MAXIMIZE )
       EXIT
     ENDIF
     lnhWnd = GetWindow( lnhWnd, GW_HWNDNEXT )
  ENDDO

  *** Close the 'failed to open' MUTEX handle
  CloseHandle( lnMutexHandle )
ELSE
  *** Add a property to the FoxPro App so we can identify it again
  SetProp( _vfp.Hwnd, @lcAppName, 1)
  llRetVal = .T.
ENDIF

RETURN llRetVal



Permalink : http://www.atoutfox.org/nntp.asp?ID=0000013360
20 286 messages dans le forum • Liste complète des messages

www.atoutfox.org - Site de la Communauté Francophone des Professionnels FoxPro - v3.4.0 - © 2004-2026.
Cette page est générée par un composant COM+ développé en Visual FoxPro 9.0-SP2-HF3