Windows IDs overlap

Post here wxCrafter related issues / features / bugs
coder99
CodeLite Expert
Posts: 143
Joined: Wed Oct 22, 2008 6:50 am
Contact:

Windows IDs overlap

Post by coder99 » Sat Dec 28, 2013 12:04 am

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?
Win 10 64-bit, MSVC 2010/2015/2017, wxWidgets 3.1.0, CodeLite 12.0
Fight Spam, report it with wxSR

User avatar
eranif
CodeLite Plugin
Posts: 5934
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Windows IDs overlap

Post by eranif » Sat Dec 28, 2013 12:32 am

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
Make sure you have read the HOW TO POST thread

coder99
CodeLite Expert
Posts: 143
Joined: Wed Oct 22, 2008 6:50 am
Contact:

Re: Windows IDs overlap

Post by coder99 » Sat Dec 28, 2013 1:03 am

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.
Win 10 64-bit, MSVC 2010/2015/2017, wxWidgets 3.1.0, CodeLite 12.0
Fight Spam, report it with wxSR

DavidGH
CodeLite Plugin
Posts: 583
Joined: Wed Sep 03, 2008 7:26 pm
Contact:

Re: Windows IDs overlap

Post by DavidGH » Sat Dec 28, 2013 2:51 am

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

coder99
CodeLite Expert
Posts: 143
Joined: Wed Oct 22, 2008 6:50 am
Contact:

Re: Windows IDs overlap

Post by coder99 » Sat Dec 28, 2013 3:03 am

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.
Win 10 64-bit, MSVC 2010/2015/2017, wxWidgets 3.1.0, CodeLite 12.0
Fight Spam, report it with wxSR

Post Reply