May 10, 2009

wxWidget

#ifndef __text_UI__
#define __text_UI__

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include

class wxWidgetsApp : public wxApp
{
public:
virtual bool OnInit();
};

DECLARE_APP(wxWidgetsApp)

class MyFrame1 : public wxFrame
{
protected:
wxTextCtrl* m_textCtrl1;
wxButton* m_button1;

void OnButton( wxCommandEvent& event );

public:
MyFrame1( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("TEST"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,300 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL );
~MyFrame1();

};

enum{
wxID_TEXT = 1000,
wxID_BTN
};

#endif //__text_UI__

//-----------------------------------------------------------------------------------------------------------------------------//
#include "text_UI.h"

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 );

wxFlexGridSizer* fgSizer1;
fgSizer1 = new wxFlexGridSizer( 2, 2, 0, 0 );
fgSizer1->SetFlexibleDirection( wxBOTH );
fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
///m_textCtrl1
m_textCtrl1 = new wxTextCtrl( this, wxID_TEXT, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer1->Add( m_textCtrl1, 0, wxALL, 5 );
///m_button1
m_button1 = new wxButton( this, wxID_BTN, wxT("MyButton"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer1->Add( m_button1, 0, wxALL, 5 );

bSizer1->Add( fgSizer1, 1, wxEXPAND, 5 );

this->SetSizer( bSizer1 );
this->Layout();

///onnect Events
m_button1->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::OnButton ), NULL, this );
}

MyFrame1::~MyFrame1()
{
m_button1->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::OnButton ), NULL, this );
}

#include

IMPLEMENT_APP(wxWidgetsApp)

bool wxWidgetsApp::OnInit()
{
MyFrame1* dialog = new MyFrame1( (wxWindow*)NULL );
dialog->Show();
SetTopWindow( dialog );
return true;
}

#include

void MyFrame1::OnButton( wxCommandEvent& event )
{
// TODO: Implement OnButton
wxString str;
str = _T("AAA");
m_textCtrl1->SetValue(str);
}

0推薦此文章
Today's Visitors: 0 Total Visitors: 14
Personal Category: 程式 Topic: technology / tech info / programming
Next in This Category: 幾個寫程式時,我常用到的查詢網站

誰來收藏
Loading ...
unlog_NVPO 0