2010-01-22 54 views
0

我用wxwidgets制作一个简单的窗口。我怎样才能改变边界? 另外我怎样才能用右箭头按钮按下灭?函数(OnClose)?如何更改边框?

#include <wx/wx.h> 

class _Frame: public wxFrame 
{ 
    public: 
     _Frame(wxFrame *frame, const wxString& title); 
    private: 
    void OnClose(wxCloseEvent& event); 
     DECLARE_EVENT_TABLE() 
}; 

BEGIN_EVENT_TABLE(_Frame, wxFrame) 
END_EVENT_TABLE() 

_Frame::_Frame(wxFrame *frame, const wxString& title) 
    : wxFrame(frame, -1, title) 
{} 

void _Frame::OnClose(wxCloseEvent &event) 
{ 
    Destroy(); 
} 

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

IMPLEMENT_APP(_App); 

bool _App::OnInit() 
{ 
    _Frame* frame = new _Frame(0L, _("wxWidgets Application Template")); 
    frame->Show(); 

    return true; 
} 
+0

请勿使用下划线开始名称。这些名称是为编译器保留的。例如。用于标准头文件中的宏。 – MSalters 2010-01-22 12:58:46

+0

你想以什么方式改变边界? – RickNotFred 2010-01-22 13:10:43

回答

1

要关闭窗口向右箭头,你所需要的疏水阀EVT_CHAR或EVT_KEY_DOWN像这样:

头文件:

void OnChar(wxKeyEvent& event); 

源文件:

void _Frame::OnChar(wxKeyEvent& event) 
{ 
    if (event.GetKeyCode() == WXK_RIGHT) 
    { 
    wxCommandEvent close(wxEVT_CLOSE_WINDOW); 
    AddPendingEvent(close); 
    } 
    event.Skip(); 
} 

BEGIN_EVENT_TABLE(_Frame, wxFrame) 
    EVT_CHAR(_Frame::OnChar) 
END_EVENT_TABLE() 
1

更改边框(通过设置不同的wxBORDER_XXX样式)不适用于所有窗口/底部l平台,所以如果你真的需要这样做,你最好重新创建窗口。