adding components to panel or window

hi guys I'm just playing around with wxwidgets,I'm trying to add a button to my frame,I have something wrong but I'm not sure what I think it could be the validator I tried making an Validator object to pass but it tells me it's private

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
  bool yguyguyApp::OnInit()
{

    wxFrame *frame = new wxFrame((wxFrame*) NULL, -1, _T("Hello wxWidgets World"));
	frame->CreateStatusBar();
	frame->SetStatusText(_T("Hello World"));
	frame->Show(true);
	SetTopWindow(frame);
	std::cout << "hello wibuhdu" << std::endl;

	wxFrame *frame2 = new wxFrame((wxFrame*) NULL, -1, _T("Hello hyguygigybdgets World"));
	frame2->CreateStatusBar();
	frame2->SetStatusText(_T("Hello World"));
	unsigned char a = 0;
	unsigned char b = 170;
	unsigned char c = 0;
	unsigned char d = 120;


	wxColour* colour = new wxColour(a,b,c,d); // use either one
	wxColour colour2(a,b,c,d);

	frame2->Show(true);
	frame2->SetBackgroundColour(colour2);
	SetTopWindow(frame2);


	wxPanel * panel = new wxPanel(frame2, 8, wxDefaultPosition, wxSize(300, 300));
	wxButton button(panel,8, "hello", wxDefaultPosition,70,0,const wxDefaultValidator,"hello");

	return true;

}


I used panel as my window,
8 as my id,
"hello" as a string
wxDefaultPosition as position
70 as size
0 as style
not sure how to add validator or what it does
and hello as a string


thanks
The size contains both width and height so you can't use a single number.
If you want it to automatically adjust the size you can use wxDefaultSize.
If you want it to be 70 pixels wide but still use the default height you can use {70, -1}.

If you don't want to specify your own validator you can use wxDefaultValidator.

Objects that inherit from wxWindow (such as wxButton) need to be created with new.
Read this for more information: https://wiki.wxwidgets.org/Avoiding_Memory_Leaks#The_wxWidgets-specific_part
Last edited on
thanks Peter =)
Topic archived. No new replies allowed.