Имя пользователя:
Пароль:
 

Показать сообщение отдельно

Аватара для Johny777

Ветеран


Сообщения: 649
Благодарности: 444

Профиль | Отправить PM | Цитировать


Tco 03,
Цитата Tco 03:
Я имею в виду реализовать вот такой вид. Чтобы, что, куда копируется было бы видно. »
вот тебе ещё лучше:

код ( замени участок "demo" в этом примере http://forum.oszone.net/post-2259324-1482.html ):
читать дальше »
Код: Выделить весь код
////////////////////////////////////////////  demo //////////////////////////////////////////////////////////////////
function GetTickCount: DWORD; external 'GetTickCount@kernel32.dll stdcall';

const
    SPACE = #32;
    KILOBYTE = 1024;
    MEGABYTE = 1048576;
    GIGABYTE = 1073741824;
    //TERABYTE = 1099511627776;
function TicksToTime(const Ticks: Single): String;
var
    hCount, mCount, sCount: Integer;
    LocalTicks: Single;
begin
    Result := '';
    if Ticks = 0 then Exit;
    
    LocalTicks := Ticks/1000;
    hCount := Round(LocalTicks) div 3600;
    LocalTicks := LocalTicks-hCount*3600;
    mCount := Round(LocalTicks) div 60;
    sCount := Round(LocalTicks-mCount*60);

    if hCount <> 0 then Result := Result + IntToStr(hCount) + SPACE + 'Hours' + SPACE;
    if mCount <> 0 then Result := Result + IntToStr(mCount) + SPACE + 'Min' + SPACE;
    if sCount <> 0 then Result := Result + IntToStr(sCount) + SPACE + 'Sec';
end;
function ConvertSize(const Bytes: Extended): String;
begin
    if Bytes < KILOBYTE then
      Result := Format('%d b', [Bytes])
    else
    if Bytes < MEGABYTE then
      Result := Format('%.2f Kb', [Bytes/KILOBYTE])
     else
    //if Bytes < GIGABYTE then
      Result := Format('%.2f Mb', [Bytes/MEGABYTE]);
end;
function RemTime(
  const StartTime: Integer;
  const NowTime: Integer;
  const Count: Extended;
  const OverallCount: Extended
): Integer;
var
    TimePast: Integer;
    CountLeft: Extended;
begin
    Result := 0;
    if Count = 0 then Exit;

    TimePast := NowTime - StartTime;
    CountLeft := OverallCount - Count;

    Result := Round(( TimePast * CountLeft ) / Count);

//    Example:   OverallCount = 1000;
//               Count = 50;
//               TimePast = 3000[Ms]  (NowTime - StartTime);
//
//               50 [Count]   -   3000[Ms]
//               950[Count]   -   x   [Ms]
//
//    Result = ( 3000[Ms] * 950[Count] ) div 50[Count]
end;



const
    NEW_LINE = #13#10;
var
    MainCopyPrgBar,FileCopyPrgBar: TNewProgressBar;
    FileStatic: TNewStaticText;
    CopyStartTime: Integer;

    function ____________________
    (
        const Msg: Integer;
        const srcFilePath: String;
        const dstFilePath: String;
        const FileBytes: Extended;
        const FileBytesCopied: Extended;
        const OverallBytes: Extended;
        const OverallBytesCopied: Extended
    ): Boolean;
    var
        OverallPercent, FilePercent: Integer;
    begin
        case Msg of
            COPY_COLLECTING_INFO: FileStatic.Caption := 'Processing: ' + srcFilePath;
            COPY_IN_PROGRESS:
            begin
                if CopyStartTime = 0 then CopyStartTime := GetTickCount();

                OverallPercent := Round( (100*OverallBytesCopied) / OverallBytes );
                FilePercent := Round( (100*FileBytesCopied) / FileBytes );
                FileCopyPrgBar.Position := FilePercent;
                MainCopyPrgBar.Position := OverallPercent;
                
                FileStatic.Caption :=
                'Copying:'                                                       + NEW_LINE +
                'Source: '  + srcFilePath                                        + NEW_LINE +
                'Dest: '      + dstFilePath                                      + NEW_LINE +
                                                                                 + NEW_LINE +
                'Overall: '   +       ConvertSize( OverallBytesCopied ) + ' of ' +
                                      ConvertSize( OverallBytes       ) + ',   ' +
                                      IntToStr(    OverallPercent     ) + '[%]'  + NEW_LINE +

                'File: '      +       ConvertSize( FileBytesCopied )    + ' of ' +
                                      ConvertSize( FileBytes       )    + ',   ' +
                                      IntToStr(    FilePercent     )    + '[%]'  + NEW_LINE +
                                                                        + NEW_LINE +
                'Remaining Time: ' +  TicksToTime( RemTime(CopyStartTime, GetTickCount, OverallBytesCopied, OverallBytes) ) + NEW_LINE +
                'Elapsed Time: '   +  TicksToTime( GetTickCount() - CopyStartTime );
            end;          
            COPY_FINISHED: MsgBox('Finish! :)', mbInformation, MB_OK);
        end;
                                                                           
        Application.ProcessMessages;

        Result := not Application.Terminated;
    end;




procedure ButtonClick(Sender: TObject);
begin
    CopyFiles('D:\Freemans Mind\', 'C:\downloads',['*'], SET_PROCESS_READONLY_FILES or SET_OVERWRITE_EXISTING_FILES, @____________________);
end;

procedure InitializeWizard();
begin
    CopyStartTime := 0;
    
    WizardForm.OuterNotebook.Hide;
    
    MainCopyPrgBar := TNewProgressBar.Create(nil);
    with MainCopyPrgBar do
    begin
        Parent:= WizardForm;
        SetBounds(ScaleX(5), ScaleY(5), WizardForm.ClientWidth-10, ScaleY(20));
    end;
    
    FileCopyPrgBar := TNewProgressBar.Create(nil);
    with FileCopyPrgBar do
    begin
        Parent:= WizardForm;
        SetBounds(ScaleX(5), ScaleY(30), WizardForm.ClientWidth-10, ScaleY(20));
    end;
    
    FileStatic := TNewStaticText.Create(WizardForm);
    with FileStatic do
    begin
        Parent := WizardForm;
        SetBounds(ScaleX(5), ScaleY(65), WizardForm.ClientWidth-10, ScaleY(20));
        Caption := '...';
    end;

    with TButton.Create(WizardForm) do
    begin
        Parent:= WizardForm;
        Left := ScaleX(0);
        Top := ScaleY(200);
        Width := ScaleY(150);
        Caption:='Copy';
        OnClick:=@ButtonClick;
    end;
end;


PS: повторюсь. Та инфа которую, ты хочешь отобразить + то, что я дополнительно отображаю высчитывается в каллбэке (функции обратного вызова)
короче прочитай внимательно пример!
можно ещё прикрутить время (оставшееся, прошедшее) для текущего файла, но я не стал перегружать код, тк думаю, что это лишнее

=====================================================================================

sergey095,
используй функцию
Код: Выделить весь код
 function CustomMessage(const MsgName: String): String; // Returns the value of the [CustomMessages] entry with the specified name.
например: свойство класса(пр. Caption, Text) := CustomMessage('infopath01');

Последний раз редактировалось Johny777, 01-12-2013 в 18:30.


Отправлено: 18:16, 01-12-2013 | #1575