## wxPanel

A panel is a window on which controls are placed. It is usually placed within a frame. It contains minimal extra functionality over and above its parent class wxWindow; its main purpose is to be similar in appearance and functionality to a dialog, but with the flexibility of having any window as a parent.

Note: if not all characters are being intercepted by your OnKeyDown or OnChar handler, it may be because you are using the wxTAB_TRAVERSAL style, which grabs some keypresses for use by child controls.

Derived from

wxWindow
wxEvtHandler
wxObject

Include files

<wx/panel.h>

Window styles

There are no specific styles for this window.

See also window styles overview.

Remarks

By default, a panel has the same colouring as a dialog.

A panel may be loaded from a wxWindows resource file (extension `wxr`).

See also

wxDialog

Members

wxPanel::wxPanel
wxPanel::~wxPanel
wxPanel::Create
wxPanel::GetDefaultItem
wxPanel::InitDialog
wxPanel::OnSysColourChanged
wxPanel::SetDefaultItem

### wxPanel::wxPanel

wxPanel()

Default constructor.

wxPanel(wxWindow* parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL, const wxString& name = "panel")

Constructor.

Parameters

parent

The parent window.

id

An identifier for the panel. A value of -1 is taken to mean a default.

pos

The panel position. A value of (-1, -1) indicates a default position, chosen by either the windowing system or wxWindows, depending on platform.

size

The panel size. A value of (-1, -1) indicates a default size, chosen by either the windowing system or wxWindows, depending on platform.

style

The window style. See wxPanel.

name

Used to associate a name with the window, allowing the application user to set Motif resource values for individual dialog boxes.

See also

wxPanel::Create

### wxPanel::~wxPanel

~wxPanel()

Destructor. Deletes any child windows before deleting the physical window.

### wxPanel::Create

bool Create(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL, const wxString& name = "panel")

Used for two-step panel construction. See wxPanel::wxPanel for details.

### wxPanel::GetDefaultItem

wxButton* GetDefaultItem() const

Returns a pointer to the button which is the default for this window, or NULL. The default button is the one activated by pressing the Enter key.

### wxPanel::InitDialog

void InitDialog()

Sends a wxInitDialogEvent, which in turn transfers data to the dialog via validators.

See also

wxInitDialogEvent

### wxPanel::OnSysColourChanged

void OnSysColourChanged(wxSysColourChangedEvent& event)

The default handler for wxEVT_SYS_COLOUR_CHANGED.

Parameters

event

The colour change event.

Remarks

Changes the panel's colour to conform to the current settings (Windows only). Add an event table entry for your panel class if you wish the behaviour to be different (such as keeping a user-defined background colour). If you do override this function, call wxEvent::Skip to propagate the notification to child windows and controls.

See also

wxSysColourChangedEvent

### wxPanel::SetDefaultItem

void SetDefaultItem(wxButton *btn)

Changes the default button for the panel.

See also

GetDefaultItem