Page 1 of 1

Generating New ID

Posted: Fri Aug 16, 2019 10:44 pm
by bandali99
I want to create an object that when created it has its own unique wxID. I saw in older posts that you can use wxNewId(); but it has been deprecated? Is there any way I could generate them at runtime?

Re: Generating New ID

Posted: Fri Aug 16, 2019 11:06 pm
by doublemax
What kind of object are you trying to create? If it's a wxWidgets class that takes an ID, use wxID_ANY. Then you can get the actual id that was assigned afterwards, e.g. with wxWindow::GetId().

If it's for another custom object, you could use ::wxNewId().

Re: Generating New ID

Posted: Sat Aug 17, 2019 6:59 pm
by bandali99
doublemax wrote: Fri Aug 16, 2019 11:06 pm What kind of object are you trying to create? If it's a wxWidgets class that takes an ID, use wxID_ANY. Then you can get the actual id that was assigned afterwards, e.g. with wxWindow::GetId().

If it's for another custom object, you could use ::wxNewId().
I'm creating a custom object with these parameters so I'm assuming I could use wxID_ANY and then create a method to access its id correct?

Code: Select all

singlesliderobj::singlesliderobj(wxPanel *parent,
	wxWindowID id,
	int mainValue, int minValue, int maxValue,
	const wxPoint& pos,
	const wxSize& size,
	long style)
also, i was looking through custom examples on the wxwidgets tutorial and they made id a type int. What's the difference if its type wxWindow and type int?

Re: Generating New ID

Posted: Sat Aug 17, 2019 8:29 pm
by Kvaz1r
bandali99 wrote: Sat Aug 17, 2019 6:59 pm also, i was looking through custom examples on the wxwidgets tutorial and they made id a type int. What's the difference if its type wxWindow and type int?
It's an alias.
Used for readability.