Generating New ID

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
bandali99
Knows some wx things
Knows some wx things
Posts: 40
Joined: Fri Jul 05, 2019 3:58 pm

Generating New ID

Post by bandali99 » Fri Aug 16, 2019 10:44 pm

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?

User avatar
doublemax
Moderator
Moderator
Posts: 14198
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Generating New ID

Post by doublemax » 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().
Use the source, Luke!

bandali99
Knows some wx things
Knows some wx things
Posts: 40
Joined: Fri Jul 05, 2019 3:58 pm

Re: Generating New ID

Post by bandali99 » Sat Aug 17, 2019 6:59 pm

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?

Kvaz1r
Earned some good credits
Earned some good credits
Posts: 133
Joined: Tue Jun 07, 2016 1:07 pm

Re: Generating New ID

Post by Kvaz1r » Sat Aug 17, 2019 8:29 pm

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.

Post Reply