Начинаем программировать на C++, C#, ассемблере(win), Qt, Python, Java, AS3.

Discussion in 'С/С++, C#, Rust, Swift, Go, Java, Perl, Ruby' started by nerezus, 29 Oct 2008.

  1. sert5vert

    sert5vert Banned

    Joined:
    14 Jun 2024
    Messages:
    31
    Likes Received:
    10
    Reputations:
    0
    Code:
    #ifndef __NONAME_H__
    #define __NONAME_H__
    
    #include <wx/artprov.h>
    #include <wx/xrc/xmlres.h>
    #include <wx/string.h>
    #include <wx/stattext.h>
    #include <wx/gdicmn.h>
    #include <wx/font.h>
    #include <wx/colour.h>
    #include <wx/settings.h>
    #include <wx/textctrl.h>
    #include <wx/button.h>
    #include <wx/sizer.h>
    #include <wx/frame.h>
    
    ///////////////////////////////////////////////////////////////////////////
    
    ///////////////////////////////////////////////////////////////////////////////
    /// Class MyFrame1
    ///////////////////////////////////////////////////////////////////////////////
    class MyFrame1 : public wxFrame
    {
    private:
    
    protected:
    wxStaticText* m_staticText1;
    wxTextCtrl* m_textCtrl1;
    wxStaticText* m_staticText2;
    wxTextCtrl* m_textCtrl2;
    wxStaticText* m_staticText3;
    wxTextCtrl* text_input;
    wxStaticText* m_staticText4;
    wxButton* m_button1;
    wxStaticText* result_label;
    
    // Virtual event handlers, overide them in your derived class
    virtual void print_result( wxCommandEvent& event ) { event.Skip(); }
    
    public:
    
    MyFrame1( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 502,300 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL );
    
    ~MyFrame1();
    
    };
    
    #endif //__NONAME_H__
    ////////////////////////////////////////////////////////////////////////////////////////
    
    class My_Window : public MyFrame1
    {
    public:
    
    My_Window(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 502,300 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL );
    
    void print_result( wxCommandEvent& event);
    
    };

    Code:
    #include <wx/wx.h>
    #include "my.hpp"
    
    ///////////////////////////////////////////////////////////////////////////
    
    class MyApp: public wxApp
    {
    virtual bool OnInit();
    };
    
    MyFrame1::MyFrame1( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )
    {
    this->SetSizeHints( wxDefaultSize, wxDefaultSize );
    
    wxBoxSizer* bSizer1;
    bSizer1 = new wxBoxSizer( wxVERTICAL );
    
    m_staticText1 = new wxStaticText( this, wxID_ANY, wxT("My_Label_1"), wxDefaultPosition, wxDefaultSize, 0 );
    m_staticText1->Wrap( -1 );
    bSizer1->Add( m_staticText1, 0, wxALL, 5 );
    
    m_textCtrl1 = new wxTextCtrl( this, wxID_ANY, wxT("MyTextBox1"), wxDefaultPosition, wxDefaultSize, 0 );
    m_textCtrl1->SetMaxLength( 0 );
    bSizer1->Add( m_textCtrl1, 0, wxALL, 5 );
    
    m_staticText2 = new wxStaticText( this, wxID_ANY, wxT("My_Label_2"), wxDefaultPosition, wxDefaultSize, 0 );
    m_staticText2->Wrap( -1 );
    bSizer1->Add( m_staticText2, 0, wxALL, 5 );
    
    m_textCtrl2 = new wxTextCtrl( this, wxID_ANY, wxT("MyTextBox2"), wxDefaultPosition, wxDefaultSize, 0 );
    m_textCtrl2->SetMaxLength( 0 );
    bSizer1->Add( m_textCtrl2, 0, wxALL, 5 );
    
    wxGridSizer* gSizer1;
    gSizer1 = new wxGridSizer( 2, 4, 0, 0 );
    
    m_staticText3 = new wxStaticText( this, wxID_ANY, wxT("EmptyBox  --->"), wxDefaultPosition, wxDefaultSize, 0 );
    m_staticText3->Wrap( -1 );
    gSizer1->Add( m_staticText3, 0, wxALL, 5 );
    
    text_input = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
    text_input->SetMaxLength( 0 );
    gSizer1->Add( text_input, 0, wxALL, 5 );
    
    m_staticText4 = new wxStaticText( this, wxID_ANY, wxT(" "), wxDefaultPosition, wxDefaultSize, 0 );
    m_staticText4->Wrap( -1 );
    gSizer1->Add( m_staticText4, 0, wxALL, 5 );
    
    m_button1 = new wxButton( this, wxID_ANY, wxT("CLICK ME!"), wxDefaultPosition, wxDefaultSize, 0 );
    gSizer1->Add( m_button1, 0, wxALL, 5 );
    
    result_label = new wxStaticText( this, wxID_ANY, wxT("About to change..."), wxDefaultPosition, wxDefaultSize, 0 );
    result_label->Wrap( -1 );
    gSizer1->Add( result_label, 0, wxALL, 5 );
    
    bSizer1->Add( gSizer1, 1, wxEXPAND, 5 );
    
    this->SetSizer( bSizer1 );
    this->Layout();
    
    // Connect Events
    m_button1->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::print_result ), NULL, this );
    }
    
    My_Window::My_Window(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style)
    : MyFrame1(parent, id, title, pos, size)
    {
    }
    
    void My_Window::print_result(wxCommandEvent& event )
    {
    result_label->SetLabel(wxT("EVENT SUCCESSFULLY PROCESSED!"));
    }
    
    MyFrame1::~MyFrame1()
    {
    // Disconnect Events
    m_button1->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::print_result ), NULL, this );
    
    }
    
    IMPLEMENT_APP(MyApp)
    
    bool MyApp::OnInit()
    {
    My_Window *frame = new My_Window(NULL, 1, wxT("My Window"), wxPoint(100,100), wxSize( 740,350 ));
    frame->Show(true);
    SetTopWindow(frame);
    return true;
    }
    
    wxWidgets c++ form with inputs, label and button.

    Скажите, как подключить сюда фоновый процесс, который бы работал паралелльно программе и её форме?