牵着老婆满街逛

严以律己,宽以待人. 三思而后行.
GMail/GTalk: yanglinbo#google.com;
MSN/Email: tx7do#yahoo.com.cn;
QQ: 3 0 3 3 9 6 9 2 0 .

WxWidgets Hellow World

 

/*
 * hworld.cpp
 * Hello world sample by Robert Roebling
 
*/


#include 
"wx/wx.h" 

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

class MyFrame: public wxFrame
{
public:

    MyFrame(
const wxString& title, const wxPoint& pos, const wxSize& size);

    
void OnQuit(wxCommandEvent& event);
    
void OnAbout(wxCommandEvent& event);

    DECLARE_EVENT_TABLE()
}
;

enum
{
    ID_Quit 
= 1,
    ID_About,
}
;

BEGIN_EVENT_TABLE(MyFrame, wxFrame)
    EVT_MENU(ID_Quit, MyFrame::OnQuit)
    EVT_MENU(ID_About, MyFrame::OnAbout)
END_EVENT_TABLE()

IMPLEMENT_APP(MyApp)

bool MyApp::OnInit()
{
    MyFrame 
*frame = new MyFrame( _T("Hello World"), wxPoint(50,50), wxSize(450,340) );
    frame
->Show(TRUE);
    SetTopWindow(frame);
    
return TRUE;
}
 

MyFrame::MyFrame(
const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame((wxFrame 
*)NULL, -1, title, pos, size)
{
    wxMenu 
*menuFile = new wxMenu;

    menuFile
->Append( ID_About, _T("&About") );
    menuFile
->AppendSeparator();
    menuFile
->Append( ID_Quit, _T("E&xit") );

    wxMenuBar 
*menuBar = new wxMenuBar;
    menuBar
->Append( menuFile, _T("&File") );

    SetMenuBar( menuBar );

    CreateStatusBar();
    SetStatusText( _T(
"Welcome to wxWindows!") );
}


void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
    Close(TRUE);
}


void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
    wxMessageBox(_T(
"This is a wxWindows Hello world sample"),
        _T(
"About Hello World"), wxOK | wxICON_INFORMATION, this);
}




我做了一个VS2005的项目,提供给大家下载:
WxProject.rar

还没有在linux下面编译过,哈哈.....
还从来没有写过linux下面的窗口程序,
有时间编译跑跑,感觉肯定是不错的.

posted on 2008-01-01 14:58 杨粼波 阅读(281) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理