IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C++Builder Discussion :

utilisation d'une ProgressBar [FAQ]


Sujet :

C++Builder

  1. #1
    Nouveau Candidat au Club
    Inscrit en
    Décembre 2004
    Messages
    1
    Détails du profil
    Informations forums :
    Inscription : Décembre 2004
    Messages : 1
    Points : 1
    Points
    1
    Par défaut utilisation d'une ProgressBar
    Bonjour je voudrais utiliser une progressbar avec un copyFile pour voir l'avancement de mon copier mais je sais pas du tout comment faire
    Merci d'avance.

  2. #2
    Rédacteur/Modérateur
    Avatar de Trap D
    Profil pro
    Inscrit en
    Septembre 2003
    Messages
    4 942
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2003
    Messages : 4 942
    Points : 6 498
    Points
    6 498
    Par défaut
    Salut
    Si tu es sous NT ou W200 ou XP essaye d'utiliser l'API CopyFileEx :
    Citation Envoyé par MSDN
    CopyFileEx
    The CopyFileEx function copies an existing file to a new file. This function preserves extended attributes, OLE structured storage, NTFS alternate data streams, and file attributes. Security attributes for the existing file are not copied to the new file.

    BOOL CopyFileEx(
    LPCTSTR lpExistingFileName, // name of existing file
    LPCTSTR lpNewFileName, // name of new file
    LPPROGRESS_ROUTINE lpProgressRoutine, // callback function
    LPVOID lpData, // callback parameter
    LPBOOL pbCancel, // cancel status
    DWORD dwCopyFlags // copy options
    );
    Parameters
    lpExistingFileName
    [in] Pointer to a null-terminated string that specifies the name of an existing file.
    Windows NT/2000 or later: In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to nearly 32,000 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see File Name Conventions.

    Windows 95/98/Me: This string must not exceed MAX_PATH characters.

    lpNewFileName
    [in] Pointer to a null-terminated string that specifies the name of the new file.
    Windows NT/2000 or later: In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to nearly 32,000 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see File Name Conventions.

    Windows 95/98/Me: This string must not exceed MAX_PATH characters.

    lpProgressRoutine
    [in] Specifies the address of a callback function of type LPPROGRESS_ROUTINE that is called each time another portion of the file has been copied. This parameter can be NULL. For more information on the progress callback function, see CopyProgressRoutine.
    lpData
    [in] Specifies an argument to be passed to the callback function. This parameter can be NULL.
    pbCancel
    [in] Pointer to a Boolean variable that can be used to cancel the operation. If this flag is set to TRUE during the copy operation, the operation is canceled.
    dwCopyFlags
    [in] Specifies how the file is to be copied. This parameter can be a combination of the following values. Value Meaning
    COPY_FILE_FAIL_IF_EXISTS The copy operation fails immediately if the target file already exists.
    COPY_FILE_RESTARTABLE Progress of the copy is tracked in the target file in case the copy fails. The failed copy can be restarted at a later time by specifying the same values for lpExistingFileName and lpNewFileName as those used in the call that failed.


    Return Values
    If the function succeeds, the return value is nonzero.

    If the function fails, the return value is zero. To get extended error information call GetLastError.
    Pour la routine "Progress"
    Citation Envoyé par MSDN
    CopyProgressRoutine
    The CopyProgressRoutine function is an application-defined callback function used with the CopyFileEx and MoveFileWithProgress functions. It is called when a portion of a copy or move operation is completed. The LPPROGRESS_ROUTINE type defines a pointer to this callback function. CopyProgresRoutine is a placeholder for the application-defined function name.

    DWORD CALLBACK CopyProgressRoutine(
    LARGE_INTEGER TotalFileSize, // file size
    LARGE_INTEGER TotalBytesTransferred, // bytes transferred
    LARGE_INTEGER StreamSize, // bytes in stream
    LARGE_INTEGER StreamBytesTransferred, // bytes transferred for stream
    DWORD dwStreamNumber, // current stream
    DWORD dwCallbackReason, // callback reason
    HANDLE hSourceFile, // handle to source file
    HANDLE hDestinationFile, // handle to destination file
    LPVOID lpData // from CopyFileEx
    );
    Parameters
    TotalFileSize
    [in] Specifies the total size of the file, in bytes.
    TotalBytesTransferred
    [in] Specifies the total number of bytes transferred from the source file to the destination file since the copy operation began.
    StreamSize
    [in] Specifies the total size of the current file stream, in bytes.
    StreamBytesTransferred
    [in] Specifies the total number of bytes in the current stream that have been transferred from the source file to the destination file since the copy operation began.
    dwStreamNumber
    [in] Handle to the current stream. The first time CopyProgressRoutine is called, the stream number is 1.
    dwCallbackReason
    [in] Specifies the reason that CopyProgressRoutine was called. This parameter can be one of the following values. Value Meaning
    CALLBACK_CHUNK_FINISHED Another part of the data file was copied.
    CALLBACK_STREAM_SWITCH Another stream was created and is about to be copied. This is the callback reason given when the callback routine is first invoked.


    hSourceFile
    [in] Handle to the source file.
    hDestinationFile
    [in] Handle to the destination file
    lpData
    [in] The argument passed to CopyProgressRoutine by the CopyFileEx or MoveFileWithProgress function.
    Return Values
    The CopyProgressRoutine function should return one of the following values.

    Value Meaning
    PROGRESS_CONTINUE Continue the copy operation.
    PROGRESS_CANCEL Cancel the copy operation and delete the destination file.
    PROGRESS_STOP Stop the copy operation. It can be restarted at a later time.
    PROGRESS_QUIET Continue the copy operation, but stop invoking CopyProgressRoutine to report progress.


    Remarks
    An application can use this information to display a progress bar that shows the total number of bytes copied as a percent of the total file size.

Discussions similaires

  1. Utilisation d'une progressBar
    Par Jean-Luc80 dans le forum VB.NET
    Réponses: 16
    Dernier message: 22/12/2013, 08h11
  2. Utilisation d'une Progressbar
    Par Rogue 9 dans le forum Windows Forms
    Réponses: 7
    Dernier message: 22/05/2008, 16h48
  3. [VB6] Utiliser une Progressbar (barre de progression)
    Par Sytchev3 dans le forum VB 6 et antérieur
    Réponses: 7
    Dernier message: 29/03/2006, 14h57
  4. Utilisation d'une progressbar ?
    Par RiiiDD dans le forum Composants VCL
    Réponses: 6
    Dernier message: 08/09/2005, 11h28
  5. [C#] Utilisation d'une ProgressBar pour un téléchargement
    Par snoof dans le forum Windows Forms
    Réponses: 10
    Dernier message: 04/10/2004, 19h37

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo