wxWidgets随笔(2)-hello,world
生活随笔
收集整理的這篇文章主要介紹了
wxWidgets随笔(2)-hello,world
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
#include <wx/wxprec.h>
#ifndef WX_PRECOMP#include <wx/wx.h>
#endif// application class
//派生自wxApp的類
class wxMiniApp : public wxApp
{
public:// function called at the application initializationvirtual bool OnInit();void OnClick(wxCommandEvent& event);
};IMPLEMENT_APP(wxMiniApp);
//click方法響應click按鈕的事件,退出窗口
void wxMiniApp::OnClick(wxCommandEvent& event) {GetTopWindow()->Close();}bool wxMiniApp::OnInit()
{// create a new frame and set it as the top most application window//wxFrame實例并設置第一窗口SetTopWindow( new wxFrame( NULL, -1, wxT(""), wxDefaultPosition, wxSize( 100, 50) ) );// create new button and assign it to the main frame//創建退出按鈕new wxButton( GetTopWindow(), wxID_EXIT, wxT("Click!") );// connect button click event with event handler//響應退出事件Connect(wxID_EXIT, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(wxMiniApp::OnClick) );// show main frame//顯示應用程序窗口GetTopWindow()->Show();// enter the application's main loopreturn true;
}
總結
以上是生活随笔為你收集整理的wxWidgets随笔(2)-hello,world的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MINA核心结构和处理消息的逻辑流程
- 下一篇: wxWidgets随笔(3)-hello