Code: Select all
void DownloadFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(e))
{
Destroy();
}
ProjectApp.h
Code: Select all
#pragma once
//! Forward declaration.
class DownloadFrame;
class ProjectApp : public wxApp
{
// Construction and destruction.
public:
//! Constructor.
ProjectApp();
//! destructor.
~ProjectApp();
// Public interface.
public:
//! Initializes the application.
virtual bool OnInit(void);
// Private data members.
private:
wxWindowPtr<DownloadFrame> downloader_;
Code: Select all
#include "pch.h"
#include "ProjectApp.h"
#include "DownloadFrame.h"
//! Macro will allow wxWidgets to create the application object during program execution.
IMPLEMENT_APP(ProjectApp)
//! Constructor.
ProjectApp::ProjectApp()
{ }
ProjectApp::~ProjectApp()
{ }
bool ProjectApp::OnInit(void)
{
if (!wxApp::OnInit())
return false;
downloader_.reset(new DownloadFrame());
downloader_->Show(true);
return true;
}
Code: Select all
#pragma once
class DownloadFrame : public wxFrame
{
// Construction and destruction.
public:
//! Constructor.
DownloadFrame();
//! Destructor.
~DownloadFrame();
// Private interface.
private:
//! On close event handler.
void OnCloseWindow(wxCloseEvent& WXUNUSED(e));
//! On cancel event handler.
void OnCancel(wxCommandEvent& WXUNUSED(e));
// Any class wishing to process wxWidgets events must use this macro.
wxDECLARE_EVENT_TABLE();
//
// Private data members.
//
private:
//! Download button.
wxWindowPtr<wxButton> downloadBtn_;
//! Button sizer.
wxSharedPtr<wxBoxSizer> btnSizer_;
//! Top sizer.
wxSharedPtr<wxBoxSizer> topSizer_;
};
Code: Select all
#include "pch.h"
#include "DownloadFrame.h"
//! Event table.
BEGIN_EVENT_TABLE(DownloadFrame, wxFrame)
EVT_CLOSE(DownloadFrame::OnCloseWindow)
END_EVENT_TABLE()
DownloadFrame::DownloadFrame()
: wxFrame(NULL, wxID_ANY, wxT("Downloader"))
{
topSizer_.reset(new wxBoxSizer(wxHORIZONTAL));
//! Creates button.
btnSizer_.reset(new wxBoxSizer(wxVERTICAL));
downloadBtn_.reset(new wxButton(this, wxID_ANY, wxT("Cancel"), wxDefaultPosition, wxSize(100, 30)));
downloadBtn_->Bind(wxEVT_BUTTON, &DownloadFrame::OnCancel, this);
btnSizer_->Add(downloadBtn_.get(), wxSizerFlags().Proportion(0).Border(wxALL, 10).Right());
topSizer_->Add(btnSizer_.get(), wxSizerFlags().Proportion(1).Center());
}
void DownloadFrame::OnCancel(wxCommandEvent& WXUNUSED(e))
{
wxMessageBox(wxT("Downloading has been canceled"), wxT("Download"), wxOK, this, wxDefaultCoord, wxDefaultCoord);
}
void DownloadFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(e))
{
Destroy();
}
class wxSharedPtr< T > http://docs.wxwidgets.org/trunk/classwx ... _01_4.html
или
class wxWindowPtr< T > http://docs.wxwidgets.org/trunk/classwx ... _01_4.html
Спасибо.