Skip navigation.
The QNX Community Portal

View topic - Retrieving Widget Names

Retrieving Widget Names

Isn't the name clear?

Retrieving Widget Names

Postby steven_lougheed » Thu Jul 26, 2007 6:41 pm

Is there a way to retrieve the name of a widget generated by PhAB within a callback?

For example:

I have two label widgets named "label_widget_0" and "label_widget_1" both using the same realized callback "". I'd like to be able to determine which widget is being realized in the callback without using the user data or comparing against the PhAB generated ABW index. (i.e. I could do if(widget == ABW_label_widget_0) but that requires a hard coded solution).

Since we enforce a naming scheme within PhAB it would be much more convenient to parse the name string so I could determine that it was widget 0 or 1 that was being realized.

Anyone know if this text is stored somewhere or is it only used by PhAB to generate the ABW index name?
Active Member
Posts: 16
Joined: Fri Feb 23, 2007 6:30 pm

RE: Retrieving Widget Names

Postby bedmond » Thu Jul 26, 2007 8:17 pm

I don't know of any way to get the string. Usually ApName() is used to this type of thing but it is not much different than using the ABW_ value:

if ( ApName( widget ) == ABN_widget1 ) {
/* do widget1 processing */

Phab stores the widgets as indexs and defines when it generates the code.
Active Member
Posts: 19
Joined: Tue Apr 17, 2007 2:13 am

Postby ingraham » Thu Jul 26, 2007 9:39 pm

ApInstanceName() might do what you want.

char *generated_string....
if (strcmp(ApInstanceName(widget), generated_string) == 0)...

Make sure you look at the ApInstanceName() documentation. The strings aren't retained by default, so you have to change a setting in PhAB.

Incidentally, I handle this problem slightly differently. At startup, we assign all the ABW_xxx pointers into an array. Then we put a value corresponding to the index in Pt_ARG_USER_DATA. Pull the number out of Pt_ARG_USER_DATA and then you can directly use widget_array[widget_index]. This adds the work of dealing with Pt_ARG_USER_DATA, but saves the work of dealing with strings and the space of storing the strings in the running project.

-James Ingraham
Sage Automation, Inc.
Senior Member
Posts: 160
Joined: Wed Nov 05, 2003 2:25 pm
Location: Texas

Postby steven_lougheed » Fri Jul 27, 2007 2:01 pm

Excellent. Thanks that's exactly what I was looking for.

I think I will take your suggestion and assign the USER_DATA at runtime. We had been doing something similar, but backwards i.e. assigning the USER_DATA in PhAB and then hardcoding an array of widgets that would line up with these numbers. Your solution makes a lot more sense.

Just in case anyone is reading this post later looking for the option in PhAB to store the strings, it is the aptly named "Store Names for ApInstanceName()" under the "Generate Options" tab in Project Properties. The document is here: ... herOptions
Active Member
Posts: 16
Joined: Fri Feb 23, 2007 6:30 pm

Return to GUI Programming

Who is online

Users browsing this forum: Bing [Bot] and 3 guests