In building the GUI using wxCR 1.3 or a project with both a main frame and several dialog in the same wxcp file, the windows IDs overlap if the option "Generate Windows ID" is set to true and if both the main frame a dialog have ID set to custom IDs.
As well, I am curious as to why the enums are part of a class - aren't windows IDs global so that each is unique and can be used to find a window using only its ID?
Windows IDs overlap
-
- CodeLite Expert
- Posts: 167
- Joined: Wed Oct 22, 2008 6:50 am
- Contact:
Windows IDs overlap
Win 10/11 64-bit, MSVC 2019/2022, wxWidgets 3.2.1, CodeLite 17.0 Mint 21.2
- eranif
- CodeLite Plugin
- Posts: 6375
- Joined: Wed Feb 06, 2008 9:29 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: Windows IDs overlap
In which case you need to find a window by its ID? I never needed that ( and I am using wxWidgets for about 10 years now )coder99 wrote: find a window using only its ID?
To get a window I simply use the member variable that holds a pointer to it.
wxCrafter does not use the MFC style event table (BEGIN_EVENT_TABLE etc) it uses the Connect() method, this means that there are no "global" event handler macros like: EVT_COMMAND(WIN_ID, ...) - so there is no need for it to be unique project wise
For toolbars etc - the ID is unique per event loop, and in case of dialogs, they got their own event loop (the modal ones at least) so its perfectly fine to have a Toolbar's tool with the same ID one in wxFrame and second in a wxDialog
In wxCrafter, all IDs are unique within the same "top-level" window (wxFrame, wxDialog, wxWizard etc)
Ofc, there are other ways to assign custom ID to windows within wxCrafter which might fit your needs, see this post:
http://forums.codelite.org/viewtopic.php?f=18&t=2316
Eran
Make sure you have read the HOW TO POST thread
-
- CodeLite Expert
- Posts: 167
- Joined: Wed Oct 22, 2008 6:50 am
- Contact:
Re: Windows IDs overlap
I did indeed have to use the extra header files which includes my IDs so I could continue testing while this issue is resolved.
When using wxFB, I had wxFB use the connect/disconnect method as well.
The reason I am currently using FindWindowById is that I need to find a window inside a wxKeyEventHandler and that seemed to be the easiest method in this instance.
When using wxFB, I had wxFB use the connect/disconnect method as well.
The reason I am currently using FindWindowById is that I need to find a window inside a wxKeyEventHandler and that seemed to be the easiest method in this instance.
Win 10/11 64-bit, MSVC 2019/2022, wxWidgets 3.2.1, CodeLite 17.0 Mint 21.2
-
- CodeLite Plugin
- Posts: 819
- Joined: Wed Sep 03, 2008 7:26 pm
- Contact:
Re: Windows IDs overlap
Hi,
However if you do need to use wxWindow::FindWindowById, its second parameter, parent, allows you to restrict your search to one container.
Regards,
David
It depends on your exact situation, of course, but usually you can get that easily with wxEvent::GetEventObject.The reason I am currently using FindWindowById is that I need to find a window inside a wxKeyEventHandler and that seemed to be the easiest method in this instance.
However if you do need to use wxWindow::FindWindowById, its second parameter, parent, allows you to restrict your search to one container.
Regards,
David
-
- CodeLite Expert
- Posts: 167
- Joined: Wed Oct 22, 2008 6:50 am
- Contact:
Re: Windows IDs overlap
Thank you, DAvidGH,
I'll have to try those suggestion once I get my project back to the point where I can try it out
I like them better than FindByID, but had never really thought of trying them.
I'll have to try those suggestion once I get my project back to the point where I can try it out
I like them better than FindByID, but had never really thought of trying them.
Win 10/11 64-bit, MSVC 2019/2022, wxWidgets 3.2.1, CodeLite 17.0 Mint 21.2