?
#include <wx\wx.h>
#include <wx\file.h>
#include <sstream>
//#include <windows.h>
const int ID_BUTTON_CHOOSEFILE = 1000;
class FileTransferServerDialog : public wxDialog
{
public:
FileTransferServerDialog(const wxChar* title, int xpos, int ypos, int width, int height)
: wxDialog(NULL, -1, title, wxPoint(xpos, ypos), wxSize(width, height))
{
pStaticTextFileName_ = new wxStaticText(this, -1, "Dateiname:", wxPoint(10, 10), wxSize(200, 20));
pStaticTextFileSize_ = new wxStaticText(this, -1, "Dateigröße:", wxPoint(10, 30), wxSize(200, 20));
pButtonChooseFile_ = new wxButton(this, ID_BUTTON_CHOOSEFILE, "Datei auswählen", wxPoint(210, 30), wxSize(90, 23));
pGaugeFileTransferProgress = new wxGauge(this, -1, NULL, wxPoint(10, 60), wxSize(300, 20), wxGA_SMOOTH);
pGaugeFileTransferProgress->SetRange(100);
pGaugeFileTransferProgress->SetValue(50);
pStaticTextFileTransferSpeed_ = new wxStaticText(this, -1, "Geschwindigkeit: 16 kb/s", wxPoint(10, 85), wxSize(200, 20));
}
void FileTransferServerDialog::onButtonChooseFile(wxCommandEvent &event)
{
wxFileDialog* pFileChooser = new wxFileDialog(this);
if(pFileChooser->ShowModal() == wxID_OK)
{
wxFile file;
file.Open(pFileChooser->GetPath());
std::ostringstream messageStream;
messageStream << "Dateigröße: " << file.Length();
pStaticTextFileName_->SetLabel(wxString("Dateiname: ") + pFileChooser->GetFilename());
pStaticTextFileSize_->SetLabel(messageStream.str().c_str());
}
pFileChooser->Destroy();
}
private:
DECLARE_EVENT_TABLE();
wxStaticText* pStaticTextFileName_;
wxStaticText* pStaticTextFileSize_;
wxButton* pButtonChooseFile_;
wxGauge* pGaugeFileTransferProgress;
wxStaticText* pStaticTextFileTransferSpeed_;
};
BEGIN_EVENT_TABLE(FileTransferServerDialog, wxDialog)
EVT_BUTTON(ID_BUTTON_CHOOSEFILE, FileTransferServerDialog::onButtonChooseFile)
END_EVENT_TABLE();
class FileTransferServer : public wxApp
{
bool OnInit()
{
FileTransferServerDialog* pFileTransferServerDialog = new FileTransferServerDialog("File Transfer Server", 40, 40, 350, 200);
pFileTransferServerDialog->ShowModal();
pFileTransferServerDialog->Destroy();
return false;
}
};
IMPLEMENT_APP(FileTransferServer);
wenn ich auf datei auswählen klicken...u dann eine datei aussuche..
u dann auf öffnen....kommt ein fenster error:
cant close file descriptor 3 (error 0: der vorgang wurde erfolgreich beendet)
??????????
cu