CrossPlatform GUI Programming with wxWidgets [Electronic resources]

Julian Smart; Kevin Hock; Stefan Csomor

نسخه متنی -صفحه : 261/ 26
نمايش فراداده

l xmlns="http://www.w3.org/1999/l">

  • The Frame Class

    Let's look at the frame class MyFrame. A frame is a top-level window that contains other windows, and usually has a title bar and menu bar. Here's our simple frame class declaration that we will put after the declaration of MyApp:

    // Declare our main frame class
    class MyFrame : public wxFrame
    {
    public:
    // Constructor
    MyFrame(const wxString& title);
    // Event handlers
    void OnQuit(wxCommandEvent& event);
    void OnAbout(wxCommandEvent& event);
    private:
    // This class handles events
    DECLARE_EVENT_TABLE()
    };
    

    Our frame class has a constructor, two event handlers to link menu commands to C++ code, and a macro to tell wxWidgets that this class handles events.