Page 1 of 1
Windows IDs overlap
Posted: Sat Dec 28, 2013 12:04 am
by coder99
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?
Re: Windows IDs overlap
Posted: Sat Dec 28, 2013 12:32 am
by eranif
coder99 wrote: find a window using only its ID?
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 )
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
Re: Windows IDs overlap
Posted: Sat Dec 28, 2013 1:03 am
by coder99
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.
Re: Windows IDs overlap
Posted: Sat Dec 28, 2013 2:51 am
by DavidGH
Hi,
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.
It depends on your exact situation, of course, but usually you can get that easily with wxEvent::GetEventObject.
However if you do need to use wxWindow::FindWindowById, its second parameter, parent, allows you to restrict your search to one container.
Regards,
David
Re: Windows IDs overlap
Posted: Sat Dec 28, 2013 3:03 am
by coder99
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.