dynamically created event separation
Leslie Newell
lesnewell at fmail.co.uk
Sun Feb 3 08:09:40 PST 2008
Don't make wx generate the Ids. IDs for the children of any window need
to be unique but as long as you don't conflict with the predefined wx
IDs (4999 - 5999), you can use anything you want. wxNewId() always
starts from 0 so choose a number that will be well out of the way.
Simply pick a base number and work from there:
#define FIRST_ID (1000)
for (int count=0; count<number_of_textcontrols; count++)
{
Chn_TextCtrl0[count] = new wxTextCtrl(this, count + FIRST_ID,....
}
When you receive the event, you now know that ID 1000 equates to
Chn_TextCtrl0[0] , 1001 equates to Chn_TextCtrl0[1] and so on.
Les
szurilo wrote:
> Ok, than what is the solution if i want some control that created dynamically
> and if the user press <enter> in any of them my event handler know which one
> is the sender.
> I mean i run my (client) program, the server tells it create 4 wxTextCtrl.
> The client create them and Connect() the event handler function, than it
> should assign a number for example 3 if the user press the <enter> in the
> 3th wxTextCtrl.
> getId() only tell a number(ID) that isnt help me bec. this number could be
> any number like i told you it was 121 when i check it in my program before.
>
> Szurilo
>
More information about the wx-users
mailing list