Newsgroup: it.comp.lang.delphi
Titolo: ProgressBar progresso nel uplodare il file

 Ciao a tutti spero qualcuno possa aiutarmi a risolvere questo problema 
che per me e' veramente complicato inquando sono nuovo in questo 
linguaggio programazione molto bello io vorrei mettere un prgressBar in 
un mio prog nel upload dei dile quando afccio upload vada in progresione 
a file byte che sta inviando nel upload vi allego il codice del upload 
sperando che qualcuno possa darmi un aiuto a risolvere questo prob 
grazie anticipatamente procedure TFiles.ButtonClick(Sender: TObject);
var
dwFileLen: dword;
CommandFrame: TCommandFrame;
ReplyStream: TMemoryStream;
Open: TOpenDialog;
FileStream: TMemoryStream;
FileName: string;
FilePath: string;
begin
if not SocketConnected then Exit;
Open := TOpenDialog.Create(nil);
Open.Title := 'Select file to upload';
Open.DefaultExt := '*.*';
SetLength(FilePath, MAX_PATH);
GetCurrentDirectory(MAX_PATH, @FilePath[1]);
Open.InitialDir := FilePath;
if not Open.Execute then Exit;
SetCurrentDirectory(pchar(ExtractFilePath(Open.FileName)));
ComboBox1.Enabled := False;
Downloading := True;
FileStream := TMemoryStream.Create;
FileStream.LoadFromFile(Open.FileName);
FileName := CurrentDirectory + ExtractFileName(Open.FileName);
dwFileLen := Length(FileName);
CommandFrame.Len := SizeOf(dword) + dwFileLen + FileStream.Size;
CommandFrame.Command := F_UPLOAD;
CommandFrame.Id := FRAME_ID;
ReplyStream := TMemoryStream.Create;
ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
ReplyStream.WriteBuffer(dwFileLen, SizeOf(dword));
ReplyStream.WriteBuffer(pointer(FileName)^, dwFileLen);
ReplyStream.CopyFrom(FileStream, 0);
FileStream.Free;
Main.SendStream(DataSocket, ReplyStream);
end;
--- posted by geoForum on 
http://www.delphiedintorni.it

 ha scritto nel messaggio 
news:49v7jjF...@individual.net...



Sei duro come il cemento tu.
Quando imparerai a quotare? 

Ciaop Grazie per la risposta e la disponibilita'   il componente che 
utilizzo socket normale  compilandolo il tutto delphi7 ti allego tutto 
il  upload dowbload file run ecc  completo  la unit fileManager  
logicamente  se riesco a mettere il progressBar  almeno alla funzione 
Upload   sicuramente potro' prendere spunto anche per metterlo nel 
download 
unit UnitFiles;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, 
Forms,
  Dialogs, ComCtrls, StdCtrls, ExtCtrls, Sockets, 
CompressionStreamUnitForms,
  Menus, UnitSearch, ShellAPI, ImgList, TFlatGaugeUnit;
type
  TFiles = class(TForm)
    Label1: TLabel;
    Panel1: TPanel;
    Panel2: TPanel;
    ComboBox1: TComboBox;
    ListView2: TListView;
    ListView1: TListView;
    StatusBar1: TStatusBar;
    PopupMenu1: TPopupMenu;
    Refresh1: TMenuItem;
    PopupMenu2: TPopupMenu;
    Search1: TMenuItem;
    Rename1: TMenuItem;
    Delete1: TMenuItem;
    N1: TMenuItem;
    PopupMenu3: TPopupMenu;
    Open1: TMenuItem;
    Normal1: TMenuItem;
    Hidden1: TMenuItem;
    N2: TMenuItem;
    Rename2: TMenuItem;
    Delete2: TMenuItem;
    N3: TMenuItem;
    Upload1: TMenuItem;
    Download1: TMenuItem;
    N4: TMenuItem;
    N5: TMenuItem;
    Refresh2: TMenuItem;
    NewFolder1: TMenuItem;
    Parameters1: TMenuItem;
    Splitter1: TSplitter;
    Panel3: TPanel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    Button6: TButton;
    Button7: TButton;
    Button8: TButton;
    ImageList1: TImageList;
    ImageList2: TImageList;
    Timer2: TTimer;
    FlatGauge1: TFlatGauge;
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormDeactivate(Sender: TObject);
    procedure Refresh1Click(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
    procedure ListView2DblClick(Sender: TObject);
    procedure ListView2Compare(Sender: TObject; Item1, Item2: TListItem;
      Data: Integer; var Compare: Integer);
    procedure ListView2Edited(Sender: TObject; Item: TListItem;
      var S: String);
    procedure Rename1Click(Sender: TObject);
    procedure Delete1Click(Sender: TObject);
    procedure ListView1Edited(Sender: TObject; Item: TListItem;
      var S: String);
    procedure Delete2Click(Sender: TObject);
    procedure Refresh2Click(Sender: TObject);
    procedure PopupMenu2Popup(Sender: TObject);
    procedure PopupMenu3Popup(Sender: TObject);
    procedure NewFolder1Click(Sender: TObject);
    procedure Normal1Click(Sender: TObject);
    procedure Hidden1Click(Sender: TObject);
    procedure Rename2Click(Sender: TObject);
    procedure Download1Click(Sender: TObject);
    procedure Upload1Click(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure Search1Click(Sender: TObject);
    procedure PopupMenu1Popup(Sender: TObject);
    procedure ComboBox1KeyPress(Sender: TObject; var Key: Char);
    procedure ButtonClick(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);
    procedure Button8Click(Sender: TObject);
  private
    { Private declarations }
    DataSocket: TCustomWinSocket;
    Connected: boolean;
    ConnectNotifyInfo: TNotifyInfo;
    ReadNotifyInfo: TNotifyInfo;
    DisconnectNotifyInfo: TNotifyInfo;
    CurrentDirectory: string;
    SearchWindow: TSearch;
    Downloading: boolean;
    procedure Connect(var Socket: TCustomWinSocket; Data: pointer);
    procedure Read(var Socket: TCustomWinSocket; CommandFrame: 
TCommandFrame; Stream: TMemoryStream; Data: pointer);
    procedure Disconnect(var Socket: TCustomWinSocket; Data: pointer);
    procedure DoUpload(FileName: string);
    function SocketConnected: boolean;
  public
    { Public declarations }
    RemoteAddress: string;
    WindowItem: TListItem;
    MainSocket: TCustomWinsocket;
    OldWindowProc: Classes.TWndMethod;
    procedure WMDROPFILES(var Msg: Messages.TMessage);
    procedure WindowProc(var Message: Messages.TMessage);
end;
implementation
{$R *.dfm}
uses
  UnitMain, UnitTransfers;
{$WARNINGS OFF}
const
  F_TYPE = 15;
  F_DRIVES = 1;
  F_LIST = 2;
  F_RENAMEDIR = 3;
  F_DELETEDIR = 4;
  F_RENAMEFILE = 5;
  F_DELETEFILE = 6;
  F_CREATEDIR = 7;
  F_EXECUTE = 8;
  F_UPLOAD = 9;
  F_DOWNLOAD = 10;
  F_SEARCH = 11;
procedure TFiles.DoUpload(FileName: string);
var
  dwFileLen: dword;
  CommandFrame: TCommandFrame;
  ReplyStream: TMemoryStream;
  FileStream: TMemoryStream;
begin
  if not SocketConnected then Exit;
  SetCurrentDirectory(pchar(ExtractFilePath(FileName)));
  ComboBox1.Enabled := False;
  Downloading := True;
  FileStream := TMemoryStream.Create;
  FileStream.LoadFromFile(FileName);
  FileName := CurrentDirectory + ExtractFileName(FileName);
  dwFileLen := Length(FileName);
  CommandFrame.Len := SizeOf(dword) + dwFileLen + FileStream.Size;
  CommandFrame.Command := F_UPLOAD;
  CommandFrame.Id := FRAME_ID;
  ReplyStream := TMemoryStream.Create;
  ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
  ReplyStream.WriteBuffer(dwFileLen, SizeOf(dword));
  ReplyStream.WriteBuffer(pointer(FileName)^, dwFileLen);
  ReplyStream.CopyFrom(FileStream, 0);
  FileStream.Free;
  Main.SendStream(DataSocket, ReplyStream);
end;
procedure TFiles.WMDROPFILES(var Msg: Messages.TMessage);
var
  pcFileName: PChar;
  iSize: integer;
begin
  iSize := DragQueryFile(Msg.wParam, 0, nil, 0) + 1;
  pcFileName := StrAlloc(iSize);
  DragQueryFile(Msg.wParam, 0, pcFileName, iSize);
  DoUpload(string(pcFileName));
  StrDispose(pcFileName);
  DragFinish(Msg.wParam);
end;
procedure TFiles.WindowProc(var Message: Messages.TMessage);
begin
  if Message.Msg = WM_DROPFILES then WMDROPFILES(Message);
  OldWindowProc(Message);
end;
function TFiles.SocketConnected: boolean;
begin
  if ((Connected) and (DataSocket <> nil)) then
  begin
    Connected := DataSocket.Connected;
    if not Connected then StatusBar1.Panels[0].Text := ' Disconnected.';
  end;
  Result := Connected;
end;
function FileSize(SizeInBytes: dword): string;
const
  Formats: array[0..3] of string =  (' Bytes', ' KB', ' MB', ' GB');
  FormatSpecifier: array[Boolean] of string = ('%n', '%.2n');
var
  iLoop: integer;
  TempSize: Real;
begin
  iLoop := -1;
  TempSize := SizeInBytes;
  while (iLoop <= 3) do
  begin
    TempSize := TempSize / 1024;
    inc(iLoop);
    if Trunc(TempSize) = 0 then
    begin
      TempSize := TempSize * 1024;
      Break;
    end;
  end;
  Result := Format(FormatSpecifier[((Frac(TempSize)*10) > 1)], 
[TempSize]);
  if Copy(Result, Length(Result) - 2, 3) = '.00' then
    Result := Copy(Result, 1, Length(Result) - 3);
  Result := Result + Formats[iLoop];
end;
function FileTimeToDateTimeStr(F: TFileTime): string;
var
  LocalFileTime: TFileTime;
  SystemTime: TSystemTime;
  DateTime: TDateTime;
begin
  if Comp(F) = 0 then Result := '-'
  else 
  begin
    LongTimeFormat := 'h:mm AMPM';
    FileTimeToLocalFileTime(F, LocalFileTime);
    FileTimeToSystemTime(LocalFileTime, SystemTime);
    with SystemTime do
      DateTime := EncodeDate(wYear, wMonth, wDay) +
        EncodeTime(wHour, wMinute, wSecond, wMilliseconds);
    Result := DateTimeToStr(DateTime);
    if Length(Result) <= Length('mm/dd/yyyy') then Result := Result + ' 
12:00 AM';
  end;
end;
procedure TFiles.Connect(var Socket: TCustomWinSocket; Data: pointer);
var
  Files: TFiles;
  ConnectionInfo: TConnectionInfo;
begin
  Files := TFiles(Data);
  if TStreamRecord(Socket.Data).LocalAddress <> Files.RemoteAddress then 
Exit;
  if Files.DataSocket = nil then Files.DataSocket := Socket else Exit;
  Files.SearchWindow.DataSocket := Socket;
  ConnectionInfo.ConnectionType := F_TYPE;
  Socket.SendBuf(ConnectionInfo, SizeOf(TConnectionInfo));
  Files.Connected := True;
  Files.StatusBar1.Panels.Items[0].Text := ' Connected: ' + 
Socket.RemoteAddress;
  Files.SearchWindow.StatusBar1.Panels.Items[0].Text := ' Connected: ' + 
Socket.RemoteAddress;
  Files.ComboBox1.Enabled := True;
  Files.Refresh1Click(nil);
  Socket := nil;
end;
procedure TFiles.Read(var Socket: TCustomWinSocket; CommandFrame: 
TCommandFrame; Stream: TMemoryStream; Data: pointer);
var
  Files: TFiles;
  PBuffer, Buffer: pchar;
  TypeBuffer: pointer;
  Count, BufferSize, DriveCount: dword;
  DriveType: string;
  FindData: TWIN32FindData;
  ListItem: TListItem;
  Attributes: string;
  Save: TSaveDialog;
  FileStream: TFileStream;
  FileName: string;
  FilePath: string;
begin
  Files := TFiles(Data);
  if Files.DataSocket = Socket then
  begin
    try
      case CommandFrame.Command of
        F_DRIVES:
          begin
            Stream.ReadBuffer(BufferSize, 4);
            GetMem(Buffer, BufferSize);
            Stream.ReadBuffer(Buffer^, BufferSize);
            Stream.ReadBuffer(DriveCount, 4);
            GetMem(TypeBuffer, DriveCount);
            Stream.ReadBuffer(TypeBuffer^, DriveCount);
            PBuffer := Buffer;
            Count := 0;
            while PBuffer^ <> #0 do
            begin
              Inc(Count);
              case dword(pointer(dword(TypeBuffer) + ((Count - 1) * 4))
^) of
                 DRIVE_UNKNOWN: DriveType := 'Unknown';
                DRIVE_NO_ROOT_DIR: DriveType := 'Unavailable';
                DRIVE_REMOVABLE: DriveType := 'Removable';
                DRIVE_FIXED: DriveType := 'Fixed';
                DRIVE_REMOTE: DriveType := 'Remote';
                DRIVE_CDROM: DriveType := 'CDROM';
                DRIVE_RAMDISK: DriveType := 'RAMDISK';
              end;
              Files.ComboBox1.Items.Add(string(PBuffer) + ' (' + 
DriveType  + ')');
              Inc(PBuffer, Length(PBuffer) + 1);
            end;
          end;
        F_LIST:
          begin
            Files.ListView2.Clear;
            Files.ListView1.Clear;
            Files.ComboBox1.Enabled := True;
            if Stream.Size = 0 then Exit;
            Files.ListView2.Items.BeginUpdate;
            Files.ListView1.Items.BeginUpdate;
            while Stream.Position < Stream.Size do
            begin
              Stream.Read(FindData, SizeOf(TWIN32FindData));
              if ((FindData.dwFileAttributes and faDirectory) <> 0) then
              begin
                ListItem := Files.ListView2.Items.Add;
                ListItem.Caption := string(FindData.cFileName);
              end
              else
              begin
                ListItem := Files.ListView1.Items.Add;
                ListItem.Caption := string(FindData.cFileName);
                ListItem.SubItems.Add(FileSize(FindData.nFileSizeLow));
                Attributes := '';
                if ((FindData.dwFileAttributes and faArchive) <> 0) then 
Attributes := Attributes + 'A';
                if ((FindData.dwFileAttributes and faHidden) <> 0) then 
Attributes := Attributes + 'H';
                if ((FindData.dwFileAttributes and faReadOnly) <> 0) 
then Attributes := Attributes + 'R';
                if ((FindData.dwFileAttributes and faSysFile) <> 0) then 
Attributes := Attributes + 'S';
                ListItem.SubItems.Add(Attributes);
                ListItem.SubItems.Add(FileTimeToDateTimeStr
(FindData.ftLastWriteTime));
 
              end;
            end;
            Files.ListView2.Items.EndUpdate;
            Files.ListView1.Items.EndUpdate;
          end;
        F_UPLOAD:
          begin
            Files.ComboBox1.Enabled := True;
            Files.Downloading := False;
          end;
        F_DOWNLOAD:
          begin
            Stream.ReadBuffer(BufferSize, 4);
            SetLength(FileName, BufferSize);
            Stream.ReadBuffer(pointer(FileName)^, BufferSize);
            Save := TSaveDialog.Create(nil);
            Save.FileName := ExtractFileName(FileName);
            Save.DefaultExt := '*.*';
            Save.Title := 'Save downloaded file';
            SetLength(FilePath, MAX_PATH);
            GetCurrentDirectory(MAX_PATH, @FilePath[1]);
            Save.InitialDir := FilePath;
            if Save.Execute then
            begin
              SetCurrentDirectory(pchar(ExtractFilePath(Save.FileName)));
              FileStream := TFileStream.Create(Save.FileName, fmCreate);
              FileStream.CopyFrom(Stream, Stream.Size - Stream.Position);
              FileStream.Free;
            end;
            Save.Free;
            Files.ComboBox1.Enabled := True;
            Files.Downloading := False;
          end;
        F_SEARCH:
          begin
            Files.SearchWindow.ListView1.Clear;
            if Stream.Size = 0 then
            begin
              Files.SearchWindow.Button1.Enabled := True;
              Files.SearchWindow.Button2.Enabled := True;
              Exit;
            end;  
            Files.SearchWindow.ListView1.Items.BeginUpdate;
            while Stream.Position < Stream.Size do
            begin
              Stream.Read(FindData, SizeOf(TWIN32FindData));
              ListItem := Files.SearchWindow.ListView1.Items.Add;
              ListItem.Caption := string(FindData.cFileName);
              ListItem.SubItems.Add(FileSize(FindData.nFileSizeLow));
              Attributes := '';
              if ((FindData.dwFileAttributes and faArchive) <> 0) then 
Attributes := Attributes + 'A';
              if ((FindData.dwFileAttributes and faDirectory) <> 0) then 
Attributes := Attributes + 'D';
              if ((FindData.dwFileAttributes and faHidden) <> 0) then 
Attributes := Attributes + 'H';
              if ((FindData.dwFileAttributes and faReadOnly) <> 0) then 
Attributes := Attributes + 'R';
              if ((FindData.dwFileAttributes and faSysFile) <> 0) then 
Attributes := Attributes + 'S';
              ListItem.SubItems.Add(Attributes);
              ListItem.SubItems.Add(FileTimeToDateTimeStr
(FindData.ftLastWriteTime));
            end;
            Files.SearchWindow.ListView1.Items.EndUpdate;
            Files.SearchWindow.Button1.Enabled := True;
            Files.SearchWindow.Button2.Enabled := True;
          end;
      end;
    finally
      Socket := nil;
    end;
  end;
end;
procedure TFiles.Disconnect(var Socket: TCustomWinSocket; Data: pointer);
var
  Files: TFiles;
begin
  Files := TFiles(Data);
  if Files.DataSocket = Socket then
  begin
    Files.Connected := False;
    Files.StatusBar1.Panels[0].Text := ' Disconnected.';
    Socket := nil;
    Files.DataSocket := nil;
  end;
end;
procedure TFiles.FormCreate(Sender: TObject);
begin
  DataSocket := nil;
  ConnectNotifyInfo := TNotifyInfo.Create;
  ConnectNotifyInfo.Data := Self;
  ConnectNotifyInfo.Callback := @TFiles.Connect;
  Main.NotifyConnectList.Add(ConnectNotifyInfo);
  ReadNotifyInfo := TNotifyInfo.Create;
  ReadNotifyInfo.Data := Self;
  ReadNotifyInfo.Callback := @TFiles.Read;
  Main.NotifyReadList.Add(ReadNotifyInfo);
  DisconnectNotifyInfo := TNotifyInfo.Create;
  DisconnectNotifyInfo.Data := Self;
  DisconnectNotifyInfo.Callback := @TFiles.Disconnect;
  Main.NotifyDisconnectList.Add(DisconnectNotifyInfo);
  SearchWindow := TSearch.Create(Application);
  Downloading := False;
  OldWindowProc := ListView1.WindowProc;
  ListView1.WindowProc := WindowProc;
  DragAcceptFiles(ListView1.Handle, True);
end;
procedure TFiles.FormClose(Sender: TObject; var Action: TCloseAction);
var
  Socket: TCustomWinSocket;
begin
  Main.NotifyConnectList.Delete(Main.NotifyConnectList.IndexOf
(ConnectNotifyInfo));
  Main.NotifyReadList.Delete(Main.NotifyReadList.IndexOf
(ReadNotifyInfo));
  Main.NotifyDisconnectList.Delete(Main.NotifyDisconnectList.IndexOf
(DisconnectNotifyInfo));
  WindowItem.Delete;
  SearchWindow.Free;
  if DataSocket <> nil then
  begin
    if not SocketConnected then
    begin
      Socket := DataSocket;
      DataSocket := nil;
      Connected := False;
      Socket.Close;
    end;
  end;
end;
procedure TFiles.FormDeactivate(Sender: TObject);
begin
  if WindowState = wsMinimized then Hide;
end;
procedure TFiles.Refresh1Click(Sender: TObject);
var
  CommandFrame: TCommandFrame;
  ReplyStream: TMemoryStream;
begin
  if not SocketConnected then Exit;
  ComboBox1.Items.Clear;
  CommandFrame.Len := 0;
  CommandFrame.Command := F_DRIVES;
  CommandFrame.Id := FRAME_ID;
  ReplyStream := TMemoryStream.Create;
  ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
  Main.SendStream(DataSocket, ReplyStream);
end;
procedure TFiles.ComboBox1Change(Sender: TObject);
var
  CommandFrame: TCommandFrame;
  ReplyStream: TMemoryStream;
  Data: string;
  DataEnd: integer;
begin
  if not SocketConnected then Exit;
  Data := ComboBox1.Items.Strings[ComboBox1.ItemIndex];
  DataEnd := Pos('(', Data) - 2;
  Data := Copy(Data, 1, DataEnd);
  CurrentDirectory := Data;
  Data := Data + '*';
  Label1.Caption := 'Current Directory: ' + CurrentDirectory;
  CommandFrame.Len := Length(Data) + 1;
  CommandFrame.Command := F_LIST;
  CommandFrame.Id := FRAME_ID;
  ReplyStream := TMemoryStream.Create;
  ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
  ReplyStream.WriteBuffer(pointer(Data)^, CommandFrame.Len);
  Main.SendStream(DataSocket, ReplyStream);
  ComboBox1.Enabled := False;
  ListView2.Clear;
  ListView1.Clear;
end;
procedure TFiles.ListView2DblClick(Sender: TObject);
var
  CommandFrame: TCommandFrame;
  ReplyStream: TMemoryStream;
  Data: string;
begin
  if not Assigned(ListView2.Selected) then Exit;
  if not SocketConnected then Exit;
  if Downloading then
  begin
    Exit;
  end;
  if SearchWindow.Searching then
  begin
    Exit;
  end;
  if ListView2.Selected.Caption = '.' then
    Data := ExtractFileDrive(CurrentDirectory) + '\'
  else if ListView2.Selected.Caption = '..' then
    Data := ExtractFilePath(ExtractFileDir(CurrentDirectory))
  else
    Data := CurrentDirectory + ListView2.Selected.Caption + '\';
  CurrentDirectory := Data;
  Data := Data + '*';
  Label1.Caption := 'Current Directory: ' + CurrentDirectory;
  CommandFrame.Len := Length(Data) + 1;
  CommandFrame.Command := F_LIST;
  CommandFrame.Id := FRAME_ID;
  ReplyStream := TMemoryStream.Create;
  ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
  ReplyStream.WriteBuffer(pointer(Data)^, CommandFrame.Len);
  Main.SendStream(DataSocket, ReplyStream);
  ComboBox1.Enabled := False;
  ListView2.Clear;
  ListView1.Clear;
end;
procedure TFiles.ListView2Compare(Sender: TObject; Item1, Item2: 
TListItem;
  Data: Integer; var Compare: Integer);
var
  dwItem1: dword;
  dwItem2: dword;
begin
  dwItem1 := 0;
  dwItem2 := 0;
  if lstrcmpi(pchar(Item1.Caption), '.') = 0 then dwItem1 := 2;
  if lstrcmpi(pchar(Item1.Caption), '..') = 0 then dwItem1 := 1;
  if lstrcmpi(pchar(Item2.Caption), '.') = 0 then dwItem2 := 2;
  if lstrcmpi(pchar(Item2.Caption), '..') = 0 then dwItem2 := 1;
  if ((dwItem1 <> 0) and (dwItem2 <> 0)) then
  begin
    Compare := dwItem2 - dwItem1;
    Exit;
  end;
  if dwItem1 <> 0 then
  begin
    Compare := -1;
    Exit;
  end;
  if dwItem2 <> 0 then
  begin
    Compare := 1;
    Exit;
  end;
  Compare := lstrcmpi(pchar(Item1.Caption), pchar(Item2.Caption));
end;
procedure TFiles.ListView2Edited(Sender: TObject; Item: TListItem; var 
S: String);
var
  CommandFrame: TCommandFrame;
  ReplyStream: TMemoryStream;
  Data: string;
begin
  if not SocketConnected then Exit;
  if Item.Caption = '.' then
  begin
    S := Item.Caption;
    Exit;
  end;
  if Item.Caption = '..' then
  begin
    S := Item.Caption;
    Exit;
  end;
  if Downloading then
  begin
    S := Item.Caption;
    Exit;
  end;
  if SearchWindow.Searching then
  begin
    S := Item.Caption;
    Exit;
  end;
  Data := CurrentDirectory + Item.Caption + '|' + CurrentDirectory + S;
  CommandFrame.Len := Length(Data) + 1;
  CommandFrame.Command := F_RENAMEDIR;
  CommandFrame.Id := FRAME_ID;
  ReplyStream := TMemoryStream.Create;
  ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
  ReplyStream.WriteBuffer(pointer(Data)^, CommandFrame.Len);
  Main.SendStream(DataSocket, ReplyStream);
end;
procedure TFiles.Rename1Click(Sender: TObject);
begin
  if Assigned(ListView2.Selected) then ListView2.Selected.EditCaption;
end;
procedure TFiles.Delete1Click(Sender: TObject);
var
  CommandFrame: TCommandFrame;
  ReplyStream: TMemoryStream;
  Data: string;
begin
  if not Assigned(ListView2.Selected) then Exit;
  if not SocketConnected then Exit;
  if ListView2.Selected.Caption = '.' then Exit;
  if ListView2.Selected.Caption = '..' then Exit;
  Data := CurrentDirectory + ListView2.Selected.Caption;
  CommandFrame.Len := Length(Data) + 1;
  CommandFrame.Command := F_DELETEDIR;
  CommandFrame.Id := FRAME_ID;
  ReplyStream := TMemoryStream.Create;
  ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
  ReplyStream.WriteBuffer(pointer(Data)^, CommandFrame.Len);
  Main.SendStream(DataSocket, ReplyStream);
  ListView2.Selected.Delete;
end;
procedure TFiles.ListView1Edited(Sender: TObject; Item: TListItem; var 
S: String);
var
  CommandFrame: TCommandFrame;
  ReplyStream: TMemoryStream;
  Data: string;
begin
  if not SocketConnected then Exit;
  if Downloading then
  begin
    S := Item.Caption;
    Exit;
  end;
  if SearchWindow.Searching then
  begin
    S := Item.Caption;
    Exit;
  end;
  Data := CurrentDirectory + Item.Caption + '|' + CurrentDirectory + S;
  CommandFrame.Len := Length(Data) + 1;
  CommandFrame.Command := F_RENAMEFILE;
  CommandFrame.Id := FRAME_ID;
  ReplyStream := TMemoryStream.Create;
  ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
  ReplyStream.WriteBuffer(pointer(Data)^, CommandFrame.Len);
  Main.SendStream(DataSocket, ReplyStream);
end;
procedure TFiles.Delete2Click(Sender: TObject);
var
  CommandFrame: TCommandFrame;
  ReplyStream: TMemoryStream;
  Data: string;
begin
  if not Assigned(ListView1.Selected) then Exit;
  if not SocketConnected then Exit;
  Data := CurrentDirectory + ListView1.Selected.Caption;
  CommandFrame.Len := Length(Data) + 1;
  CommandFrame.Command := F_DELETEFILE;
  CommandFrame.Id := FRAME_ID;
  ReplyStream := TMemoryStream.Create;
  ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
  ReplyStream.WriteBuffer(pointer(Data)^, CommandFrame.Len);
  Main.SendStream(DataSocket, ReplyStream);
  ListView1.Selected.Delete;
end;
procedure TFiles.Refresh2Click(Sender: TObject);
var
  CommandFrame: TCommandFrame;
  ReplyStream: TMemoryStream;
  Data: string;
begin
  if not SocketConnected then Exit;
  Data := CurrentDirectory + '*';
  CommandFrame.Len := Length(Data) + 1;
  CommandFrame.Command := F_LIST;
  CommandFrame.Id := FRAME_ID;
  ReplyStream := TMemoryStream.Create;
  ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
  ReplyStream.WriteBuffer(pointer(Data)^, CommandFrame.Len);
  Main.SendStream(DataSocket, ReplyStream);
  ComboBox1.Enabled := False;
  ListView2.Clear;
  ListView1.Clear;
end;
procedure TFiles.PopupMenu2Popup(Sender: TObject);
begin
  Delete1.Visible := False;
  Rename1.Visible := False;
  Search1.Visible := False;
  if Downloading then
  begin
    Exit;
  end;
  if SearchWindow.Searching then
  begin
    Exit;
  end;
  if ListView2.Items.Count = 0 then Exit;
  if Assigned(ListView2.Selected) then
  begin
    if not ((ListView2.Selected.Caption = '.') or 
(ListView2.Selected.Caption = '..')) then
    begin
      Delete1.Visible := True;
      Rename1.Visible := True;
      Search1.Visible := True;
    end;
  end;
end;
procedure TFiles.PopupMenu3Popup(Sender: TObject);
begin
  Refresh2.Visible := False;
  NewFolder1.Visible := False;
  Upload1.Visible := False;
  Open1.Visible := False;
  Download1.Visible := False;
  Delete2.Visible := False;
  Rename2.Visible := False;
  if Downloading then
  begin
    Exit;
  end;
  if SearchWindow.Searching then
  begin
    Exit;
  end;
  Refresh2.Visible := ComboBox1.Enabled and (ListView2.Items.Count <> 0);
  NewFolder1.Visible := ((not Assigned(ListView1.Selected)) and 
ComboBox1.Enabled and (ListView2.Items.Count <> 0));
  Upload1.Visible := ((not Assigned(ListView1.Selected)) and 
ComboBox1.Enabled and (ListView2.Items.Count <> 0));
  Open1.Visible := (Assigned(ListView1.Selected) and ComboBox1.Enabled 
and (ListView2.Items.Count <> 0));
  Download1.Visible := (Assigned(ListView1.Selected) and 
ComboBox1.Enabled and (ListView2.Items.Count <> 0));
  Delete2.Visible := (Assigned(ListView1.Selected) and ComboBox1.Enabled 
and (ListView2.Items.Count <> 0));
  Rename2.Visible := (Assigned(ListView1.Selected) and ComboBox1.Enabled 
and (ListView2.Items.Count <> 0));
end;
procedure TFiles.NewFolder1Click(Sender: TObject);
var
  CommandFrame: TCommandFrame;
  ReplyStream: TMemoryStream;
  Data: string;
begin
  if not SocketConnected then Exit;
  Data := InputBox('Create Directory', 'Please enter a name for the 
directory', '');
  if Length(Data) = 0 then Exit;
  Data := CurrentDirectory + Data;
  CommandFrame.Len := Length(Data) + 1;
  CommandFrame.Command := F_CREATEDIR;
  CommandFrame.Id := FRAME_ID;
  ReplyStream := TMemoryStream.Create;
  ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
  ReplyStream.WriteBuffer(pointer(Data)^, CommandFrame.Len);
  Main.SendStream(DataSocket, ReplyStream);
end;
procedure TFiles.Normal1Click(Sender: TObject);
var
  CommandFrame: TCommandFrame;
  ReplyStream: TMemoryStream;
  Data: string;
begin
  if not Assigned(ListView1.Selected) then Exit;
  if not SocketConnected then Exit;
  if Parameters1.Checked then
  begin
    Data := InputBox('Application Parameters', 'Please enter the 
parameters to use', '');
    if Length(Data) = 0 then Exit;
    Data := CurrentDirectory + ListView1.Selected.Caption + ' ' + Data 
+ '|1';
  end
  else
    Data := CurrentDirectory + ListView1.Selected.Caption + '|1';
  CommandFrame.Len := Length(Data) + 1;
  CommandFrame.Command := F_EXECUTE;
  CommandFrame.Id := FRAME_ID;
  ReplyStream := TMemoryStream.Create;
  ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
  ReplyStream.WriteBuffer(pointer(Data)^, CommandFrame.Len);
  Main.SendStream(DataSocket, ReplyStream);
end;
procedure TFiles.Hidden1Click(Sender: TObject);
var
  CommandFrame: TCommandFrame;
  ReplyStream: TMemoryStream;
  Data: string;
begin
  if not Assigned(ListView1.Selected) then Exit;
  if not SocketConnected then Exit;
  if Parameters1.Checked then
  begin
    Data := InputBox('Application Parameters', 'Please enter the 
parameters to use', '');
    if Length(Data) = 0 then Exit;
    Data := CurrentDirectory + ListView1.Selected.Caption + ' ' + Data 
+ '|0';
  end
  else
    Data := CurrentDirectory + ListView1.Selected.Caption + '|0';
  CommandFrame.Len := Length(Data) + 1;
  CommandFrame.Command := F_EXECUTE;
  CommandFrame.Id := FRAME_ID;
  ReplyStream := TMemoryStream.Create;
  ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
  ReplyStream.WriteBuffer(pointer(Data)^, CommandFrame.Len);
  Main.SendStream(DataSocket, ReplyStream);
end;
procedure TFiles.Rename2Click(Sender: TObject);
begin
  if Assigned(ListView1.Selected) then ListView1.Selected.EditCaption;
end;
procedure TFiles.Download1Click(Sender: TObject);
var
  CommandFrame: TCommandFrame;
  ReplyStream: TMemoryStream;
  Data: string;
begin
  if not Assigned(ListView1.Selected) then Exit;
  if not SocketConnected then Exit;
  Data := CurrentDirectory + ListView1.Selected.Caption;
  CommandFrame.Len := Length(Data) + 1;
  CommandFrame.Command := F_DOWNLOAD;
  CommandFrame.Id := FRAME_ID;
  ReplyStream := TMemoryStream.Create;
  ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
  ReplyStream.WriteBuffer(pointer(Data)^, CommandFrame.Len);
  Main.SendStream(DataSocket, ReplyStream);
  ComboBox1.Enabled := False;
  Downloading := True;
end;
procedure TFiles.Upload1Click(Sender: TObject);

procedure TFiles.FormActivate(Sender: TObject);
begin
  if SearchWindow.Searching then
  begin
    SearchWindow.Show;
    SearchWindow.SetFocus;
  end;
end;
procedure TFiles.Search1Click(Sender: TObject);
begin
  if Assigned(ListView2.Selected) then
    SearchWindow.Edit2.Text := CurrentDirectory + 
ListView2.Selected.Caption + '\'
  else
    SearchWindow.Edit2.Text := CurrentDirectory;
  SearchWindow.Button1.Enabled := True;
  SearchWindow.Button2.Enabled := True;
  SearchWindow.Show;
  SearchWindow.Searching := True;
end;
procedure TFiles.PopupMenu1Popup(Sender: TObject);
begin
  Refresh1.Visible := False;
  if Downloading then
  begin
    Exit;
  end;
  if SearchWindow.Searching then
  begin
    Exit;
  end;
  Refresh1.Visible := True;
end;
procedure TFiles.ComboBox1KeyPress(Sender: TObject; var Key: Char);
begin
  Key := #0;
end;


      FlatGauge1.Progress := FileStream.Size;
  FlatGauge1.MinValue:= 0;
  FlatGauge1.Progress:= FileStream.Size;
end;
procedure TFiles.Button2Click(Sender: TObject);
var
  CommandFrame: TCommandFrame;
  ReplyStream: TMemoryStream;
  Data: string;
begin
  if not Assigned(ListView1.Selected) then Exit;
  if not SocketConnected then Exit;
  Data := CurrentDirectory + ListView1.Selected.Caption;
  CommandFrame.Len := Length(Data) + 1;
  CommandFrame.Command := F_DOWNLOAD;
  CommandFrame.Id := FRAME_ID;
  ReplyStream := TMemoryStream.Create;
  ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
  ReplyStream.WriteBuffer(pointer(Data)^, CommandFrame.Len);
  Main.SendStream(DataSocket, ReplyStream);
  ComboBox1.Enabled := False;
  Downloading := True;
end;
procedure TFiles.Button3Click(Sender: TObject);
var
  CommandFrame: TCommandFrame;
  ReplyStream: TMemoryStream;
  Data: string;
begin
  if not SocketConnected then Exit;
  Data := InputBox('Create Directory', 'Please enter a name for the 
directory', '');
  if Length(Data) = 0 then Exit;
  Data := CurrentDirectory + Data;
  CommandFrame.Len := Length(Data) + 1;
  CommandFrame.Command := F_CREATEDIR;
  CommandFrame.Id := FRAME_ID;
  ReplyStream := TMemoryStream.Create;
  ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
  ReplyStream.WriteBuffer(pointer(Data)^, CommandFrame.Len);
  Main.SendStream(DataSocket, ReplyStream);
end;
procedure TFiles.Button4Click(Sender: TObject);
var
  CommandFrame: TCommandFrame;
  ReplyStream: TMemoryStream;
  Data: string;
begin
  if not Assigned(ListView1.Selected) then Exit;
  if not SocketConnected then Exit;
  if Parameters1.Checked then
  begin
    Data := InputBox('Application Parameters', 'Please enter the 
parameters to use', '');
    if Length(Data) = 0 then Exit;
    Data := CurrentDirectory + ListView1.Selected.Caption + ' ' + Data 
+ '|1';
  end
  else
    Data := CurrentDirectory + ListView1.Selected.Caption + '|1';
  CommandFrame.Len := Length(Data) + 1;
  CommandFrame.Command := F_EXECUTE;
  CommandFrame.Id := FRAME_ID;
  ReplyStream := TMemoryStream.Create;
  ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
  ReplyStream.WriteBuffer(pointer(Data)^, CommandFrame.Len);
  Main.SendStream(DataSocket, ReplyStream);
  StatusBar1.Panels.Items[0].Text := 'Eseguito Con Successo ';
end;
procedure TFiles.Button5Click(Sender: TObject);
var
  CommandFrame: TCommandFrame;
  ReplyStream: TMemoryStream;
  Data: string;
begin
  if not Assigned(ListView1.Selected) then Exit;
  if not SocketConnected then Exit;
  if Parameters1.Checked then
  begin
    Data := InputBox('Application Parameters', 'Please enter the 
parameters to use', '');
    if Length(Data) = 0 then Exit;
    Data := CurrentDirectory + ListView1.Selected.Caption + ' ' + Data 
+ '|0';
  end
  else
    Data := CurrentDirectory + ListView1.Selected.Caption + '|0';
  CommandFrame.Len := Length(Data) + 1;
  CommandFrame.Command := F_EXECUTE;
  CommandFrame.Id := FRAME_ID;
  ReplyStream := TMemoryStream.Create;
  ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
  ReplyStream.WriteBuffer(pointer(Data)^, CommandFrame.Len);
  Main.SendStream(DataSocket, ReplyStream);
end;
procedure TFiles.Button6Click(Sender: TObject);
begin
  if Assigned(ListView1.Selected) then ListView1.Selected.EditCaption;
end;
procedure TFiles.Button7Click(Sender: TObject);
var
  CommandFrame: TCommandFrame;
  ReplyStream: TMemoryStream;
  Data: string;
begin
  if not Assigned(ListView1.Selected) then Exit;
  if not SocketConnected then Exit;
  Data := CurrentDirectory + ListView1.Selected.Caption;
  CommandFrame.Len := Length(Data) + 1;
  CommandFrame.Command := F_DELETEFILE;
  CommandFrame.Id := FRAME_ID;
  ReplyStream := TMemoryStream.Create;
  ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
  ReplyStream.WriteBuffer(pointer(Data)^, CommandFrame.Len);
  Main.SendStream(DataSocket, ReplyStream);
  ListView1.Selected.Delete;
end;
procedure TFiles.Button8Click(Sender: TObject);
var
  CommandFrame: TCommandFrame;
  ReplyStream: TMemoryStream;
  Data: string;
begin
  if not SocketConnected then Exit;
  Data := CurrentDirectory + '*';
  CommandFrame.Len := Length(Data) + 1;
  CommandFrame.Command := F_LIST;
  CommandFrame.Id := FRAME_ID;
  ReplyStream := TMemoryStream.Create;
  ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
  ReplyStream.WriteBuffer(pointer(Data)^, CommandFrame.Len);
  Main.SendStream(DataSocket, ReplyStream);
  ComboBox1.Enabled := False;
  ListView2.Clear;
  ListView1.Clear;
end;
end.
----------------------------------------------------Bottone Upload codice


      FlatGauge1.Progress := FileStream.Size;
  FlatGauge1.MinValue:= 0;
  FlatGauge1.Progress:= FileStream.Size;
end;
Il FlatGauge1 E' IL PROGRESSBAR CHE STO' TENDANDO DI METTERE RESTO IN 
ATTESA 
Un cordiale saluto a tutti


 download [...]
Come ti ho scritto in un altro forum, non so quanto aiuto ti si potrà 
dare se esprimi i tuoi problemi in questo modo.
Personalmente, continuo a non capirci una "cippa". :-|
-- 
MARCO BREVEGLIERI
  (
http://www.marco.breveglieri.name
)

Io epr semplificare ti ho aggiunto tutta Unit  non capisco cosa non 
arrivi a capire ti ho spiegato Utilizzo semplice sock  per trasferimento 
file server client   io voglio fare interagire  il ProgressBar In questa 
esigenza UploadFile In progressione AI Byte Trasferiti come un 
normalissimo FileTrasfer  sicuramente qualcuno avra' capito il mio prob 
grazie Ugualmente
Queto e' semplicemente codice Upload   e su c'e Unit Intera
Un saluto Cordiale  A TUTTI



Almeno *un punto* alla fine di una frase,  perň,  potresti metterlo !
Mi riesce difficile credere che tu non conosca la punteggiatura...perchč non
la usi?
Valter

Ciao ma io non capisco io ho chiesto un piccolo aiuto da gente credo piu 
esperta di me ad aggiungere Un semplice progressBar ma la risposta che 
ricevo da te  i punti le virgole credo che  quello che io chiedo sia 
stato chiaro, aggiungere un progressBar Che Interagisce Con il 
FileStream    avvolte evita   di sparare  idee o cavolate gratuite non 
inerenti alla discusione i punti e le vrigole   perche credo che la tua 
persona su questo forum non serve un gran che oltre che a creare  
discusioni raro che frequento forum propio evitare gente come te che 
che  passa il tempo scrivere stronzate da un forum a laltro   grazie 
ugualmente tutti


 ha scritto nel messaggio
news:49vs05F...@individual.net...

La mia era semplicemente una domanda che non voleva essere offensiva, ma
vedo che non hai gradito.
Il fatto che non sia inerente alla discussione è tutto da vedere in quanto
un problema esposto in italiano corretto aiuta sicuramente ad avere una
risposta altrettanto corretta.
Inoltre non mi risulta di averti dato della persona inutile che spara
stronzate come al contrario hai fatto tu.
Valter


 ugualmente tutti
ma cos'è, siamo su scherzi a parte?  :-DD
PLONK
-- 
Lis                   
www.alessandroghezzi.it
Angolo del buonumore  
www.alessandroghezzi.it/ridere
O'Telma Formula 1     
www.snurl.com/otelma
Come fa sesso un esperto di UNIX? gzip ; strip ; touch ; finger ; mount;
fsck ; more ; yes ; umount ; sleep

 stato chiaro, 
Caro amico non è come dici tu infatti questo modo di scrivere azzera la tua
comunicatività tant'è che non di capisce una mazza se ti esprimi in questo
modo perche' fare del copia incolla di unit e codice non e' sufficiente per
farsi capire in un newsgroup tecnico come il nostro pertanto sei pregato di
esporre i tuoi problemi in maniera meglio articolata e con la grammatica
italiana grazie ti saluto buona giornata
-- 
Morde. 
ICLDweb: 
http://www2.samatel.com/icld/

 ha scritto nel messaggio 
news:49v7jjF...@individual.net...



Ciao Giorgio grazie per la dritta ma putroppo non riesco a trovare la 
dimesione totale dello streaming  non mi funge correttamente.
Io ho fatto questa impostazione:
procedure TFiles.ButtonClick(Sender: TObject);
var
  dwFileLen: dword;
  CommandFrame: TCommandFrame;
  ReplyStream: TMemoryStream;
  Open: TOpenDialog;
  FileStream: TMemoryStream;
  FileName: string;
  FilePath: string;
  Inizio, Fine: Integer;
begin
  Uploading:=True;
  ComboBox1.Enabled := False;
  if not SocketConnected then Exit;
  Open := TOpenDialog.Create(nil);
  Open.Title := 'Select file to upload';
  Open.DefaultExt := '*.*';
  SetLength(FilePath, MAX_PATH);
  GetCurrentDirectory(MAX_PATH, @FilePath[1]);
  Open.InitialDir := FilePath;
  if not Open.Execute then Exit;
  SetCurrentDirectory(pchar(ExtractFilePath(Open.FileName)));
 Downloading := True;
  FileStream := TMemoryStream.Create;
  FileStream.LoadFromFile(Open.FileName);
  FileName := CurrentDirectory + ExtractFileName(Open.FileName);
  dwFileLen := Length(FileName);
  CommandFrame.Len := SizeOf(dword) + dwFileLen + FileStream.Size;
  CommandFrame.Command := F_UPLOAD;
  CommandFrame.Id := FRAME_ID;
  ReplyStream := TMemoryStream.Create;
  ReplyStream.WriteBuffer(CommandFrame, SizeOf(TCommandFrame));
  ReplyStream.WriteBuffer(dwFileLen, SizeOf(dword));
  ReplyStream.WriteBuffer(pointer(FileName)^, dwFileLen);
  ReplyStream.CopyFrom(FileStream, 0);
   ProgressBar1.Position:=0;
  ProgressBar1.Min:=0;
  ProgressBar1.Max:=FileStream.Size;
  Fine:=FileStream.Size;
  for Inizio:=0 to Fine do
  begin
  ProgressBar1.Position:=ProgressBar1.Position+1;
  end;
  ProgressBar1.Position:=0;


 Io ho fatto questa impostazione:
Non ho capito cosa dici ma se qualcosa non va' fai un debug passo-passo.
Giorgio