1

我有这个编译的 WxWidgets 测试源代码,运行时,它显示一个简单的框架:

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

#include "wx-2.8/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);
}

使用这个简单的 SCons 脚本创建:

env = Environment()
env.ParseConfig('wx-config --cxxflags --libs')

env.Program(target='wxTest/wxTest.exe',source=['src/Wxwidgets.cpp'])

问题:当我运行它时它不会集中。我唯一可以关注的是左上角的红色、黄色和绿色按钮。我使用 Eclipse 作为我的 IDE,并在构建时将 scons 作为外部工具运行。

有没有人知道我做错了什么?如何让框架聚焦?

希望有人能帮助我。

4

1 回答 1

4

我假设您启动创建的原始可执行文件?这在 Mac OS X 上不起作用,请参阅我的应用程序不能被带到前面!

您必须为您的应用程序创建一个应用程序包才能在 Mac OS X 上正常工作。我对 SCons 一无所知,但也许wiki确实有帮助?

于 2009-06-05T10:25:33.527 回答