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: http://www.pickinpatchfarm.com/Avoiding_Memory_Leaks#The_wxWidgets-specific_part
Last edited on
thanks Peter =)
Registered users can post here. Sign in or register to post.
  • 452471514 2018-02-18
  • 5299351513 2018-02-18
  • 3036511512 2018-02-18
  • 4224301511 2018-02-18
  • 6975481510 2018-02-18
  • 8259761509 2018-02-18
  • 7007851508 2018-02-18
  • 7796301507 2018-02-18
  • 567811506 2018-02-18
  • 2107511505 2018-02-18
  • 8923811504 2018-02-17
  • 6039601503 2018-02-17
  • 8788931502 2018-02-17
  • 4539021501 2018-02-17
  • 661851500 2018-02-17
  • 9152461499 2018-02-17
  • 4757661498 2018-02-17
  • 981131497 2018-02-17
  • 4385321496 2018-02-17
  • 5046771495 2018-02-17