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'])

問題: 実行してもフォーカスされません。私が集中できるのは、左上隅にある赤、黄、緑のボタンだけです。IDE として Eclipse を使用し、ビルド時に scons を外部ツールとして実行します。

私が間違っていることを知っている人はいますか?フレームに焦点を合わせるにはどうすればよいですか?

私を助けてくれる人がいることを願っています。

4

1 に答える 1

4

作成された生の実行可能ファイルを開始すると思いますか?これはMacOSXでは機能しません。「マイアプリを前面に表示できない」を参照してください。

Mac OS Xで正しく動作するには、アプリのアプリケーションバンドルを作成する必要があります。SConsについては何も知りませんが、wikiが役立つかもしれません。

于 2009-06-05T10:25:33.527 に答える