apgetinstance

I am sorta new to phAB, please bear with me :wink:

I have two windows, once called base_wgt and one called openfil

When I click a button on base_wgt it opens openfil and there i would like to
type in a file name, click “ok” and the file is read and the contents appear
in a text box on base_wgt

It all works when contained in one window ie. the text box where the file
contents will be is in the same window as the rest, but when I try to
reference then across it will not work. Basically, my C code is the
openfil’s code and part of it is

window_wgt =apgetinstance(widget);
(there is also some declarations etc… above)

that works ok, it allows me to reference things to the openfil window e.g.

text_wgt = apgetwidgetptr(window_wgt,ABN_text_box);
Ptgetresource (text_wgt,pt_arg_text_string,&name,0);

fine, it returns whats in that text box in the variable “name” however, when
I try and modify this to access what is in the base_wgt’s text box it will
not work. I guess I need to change the top getinstance line to point to
base_wgt instead of openfil, but how do I do this?

Any help would be greatly appreciated,
Nick

Hello Nick,

Take a look at the PtFileSelection(). I think this will make life much easier for you.

Regards,
Dave B.


Nicholas Brown <nebrown@nebrown.freeserve.co.uk> wrote:

I am sorta new to phAB, please bear with me > :wink:

I have two windows, once called base_wgt and one called openfil

When I click a button on base_wgt it opens openfil and there i would like to
type in a file name, click “ok” and the file is read and the contents appear
in a text box on base_wgt

It all works when contained in one window ie. the text box where the file
contents will be is in the same window as the rest, but when I try to
reference then across it will not work. Basically, my C code is the
openfil’s code and part of it is

window_wgt =apgetinstance(widget);
(there is also some declarations etc… above)

that works ok, it allows me to reference things to the openfil window e.g.

text_wgt = apgetwidgetptr(window_wgt,ABN_text_box);
Ptgetresource (text_wgt,pt_arg_text_string,&name,0);

fine, it returns whats in that text box in the variable “name” however, when
I try and modify this to access what is in the base_wgt’s text box it will
not work. I guess I need to change the top getinstance line to point to
base_wgt instead of openfil, but how do I do this?

Any help would be greatly appreciated,
Nick