wxID_OPEN
. Often, however, the value of the ID is unimportant and is created automatically by calling wxWindow::NewControlId or by passing wxID_ANY
as the ID of an object.There are two ways to generate an ID. One way, is to start at a negative number, and for each new ID, return the next smallest number. This is fine for systems that can used the full range of negative numbers for an ID, as this provides more than enough IDs and it would take a very very long time to run out and wrap around. However, some systems can not use the full range of the ID value. Windows, for example, can only use 16 bit IDs, and only has about 32000 possible automatic IDs that can be generated by wxWindow::NewControlId. If the program runs long enough, depending on the program itself, using this first method would cause the IDs to wrap around into the positive ID range and cause possible clashes with any directly specified ID values.
The other way is to keep track of the IDs returned by wxWindow::NewControlId and don't return them again until the ID is completely free and not being used by any other objects. This will make sure that the ID values do not clash with one another. This is accomplished by keeping a reference count for each of the IDs that can possibly be returned by wxWindow::NewControlId. Other IDs are not reference counted.
If a created ID is not assigned to a wxWindowIDRef, then it remains reserved until it is unreserved manually with wxWindow::UnreserveControlId. However, if it is assigned to a wxWindowIDRef, then it will be unreserved automatically and will be considered free when the count is 0, and should NOT be manually unreserved.
wxWindowIDRef can store both automatic IDs from wxWindow::NewControlId as well as normal IDs. Reference counting is only done for the automatic IDs. Also, wxWindowIDRef has conversion operators that allow it to be treated just like a wxWindowID.
![]() |
[ top ] |