Getting a widget reference to a widget created by ApCreateMo

Hello.

I wanted to know if there is any way to get a widget reference from an
ApCreateModule() call.
I have a callback that has the potential to call this function several
times ( thus creating
multiple instances of a widget ). So, if I want to control how many
instances of a widget are
being created, then I either need to keep a local count of them or be
able to check to see if
any of them already exist.

Thanks in advance.

Rodney

Rodney Lott <rod@fuelcelltechnologies.ca> wrote:

Hello.

I wanted to know if there is any way to get a widget reference from an
ApCreateModule() call.
I have a callback that has the potential to call this function several
times ( thus creating multiple instances of a widget ). So, if
I want to control how many instances of a widget are being
created, then I either need to keep a local count of them or be
able to check to see if any of them already exist.

There’s no direct way to do this. Normally, this is a problem
with window modules – the best solution is to store away a copy
of ABW_ immediately after you use
ABM in the ApCreateModule() call. If you
store the pointers in a linked list, you can use the stored
widget pointers to traverse the widget family tree
(PtWidgetFamily() and others will do this) to any child
widget within the instance of your window module. To keep track
of how many copies of the module you have (and hence, how many
copies of a given widget within the module), you could write a
function that ran down the linked list, counting each iteration
until it reached the end of the list, or simply have a separate
global variable that tracked the number of copies.

One thing to watch out for: ABW_
will always point to the most recently created instance of the
widget. If you’re going to be using multiple instances of window
modules, be very careful about making assumptions in your code
about where you can and cannot use ABW_blah to reference a
widget.

I hope this is some help.


Norbert Black
QSSL Training Services

That’s exactly what I was looking for, Norbert.

Thanks very much.

Rodney Lott

Norbert Black wrote:

Rodney Lott <> rod@fuelcelltechnologies.ca> > wrote:
Hello.

I wanted to know if there is any way to get a widget reference from an
ApCreateModule() call.
I have a callback that has the potential to call this function several
times ( thus creating multiple instances of a widget ). So, if
I want to control how many instances of a widget are being
created, then I either need to keep a local count of them or be
able to check to see if any of them already exist.

There’s no direct way to do this. Normally, this is a problem
with window modules – the best solution is to store away a copy
of ABW_ immediately after you use
ABM in the ApCreateModule() call. If you
store the pointers in a linked list, you can use the stored
widget pointers to traverse the widget family tree
(PtWidgetFamily() and others will do this) to any child
widget within the instance of your window module. To keep track
of how many copies of the module you have (and hence, how many
copies of a given widget within the module), you could write a
function that ran down the linked list, counting each iteration
until it reached the end of the list, or simply have a separate
global variable that tracked the number of copies.

One thing to watch out for: ABW_<name of widget set up in PhAB
will always point to the most recently created instance of the
widget. If you’re going to be using multiple instances of window
modules, be very careful about making assumptions in your code
about where you can and cannot use ABW_blah to reference a
widget.

I hope this is some help.

Norbert Black
QSSL Training Services

Rodney Lott <rod@fuelcelltechnologies.ca> wrote:

That’s exactly what I was looking for, Norbert.

Thanks very much.

No problem. Thanks for taking the time to say so. :slight_smile:

Norbert Black
QSSL Training Services

My pleasure. You folks at QNX have been very helpful to me and very
quick at responding. Common courtesy and politeness is the least I can
offer. :slight_smile:

Have a good day!

Rodney Lott

Norbert Black wrote:

Rodney Lott <> rod@fuelcelltechnologies.ca> > wrote:
That’s exactly what I was looking for, Norbert.

Thanks very much.

No problem. Thanks for taking the time to say so. > :slight_smile:

Norbert Black
QSSL Training Services