[Q] Setting Pt_ARG_FLAGS issue

Howdy,

I’m having some trouble setting the Pt_ARG_FLAGS using
the function PtSetResource (or with PtSetResources) in
the following simple example (from the QNX documentation) :

int main( int argc, char *argv[] )
{
PtWidget_t *window,*widget;
PtArg_t args[1];
long flags;

if ((window = PtAppInit(NULL, &argc, argv, 0, NULL))
== NULL)
PtExit(1);

PtSetArg(&args[0], Pt_ARG_TEXT_STRING,
“hello world”, 0);
widget = PtCreateWidget(PtButton, window, 1, args);
PtRealizeWidget(window);

PtGetResource(widget,Pt_ARG_FLAGS,&flags,0);
printf("%ld\n",flags);

flags |= Pt_GHOST | Pt_BLOCKED;
printf("%ld\n",flags);

PtSetResource(widget,Pt_ARG_FLAGS,flags,0);

PtGetResource(widget,Pt_ARG_FLAGS,&flags,0);
printf("%ld\n",flags);

PtMainLoop();
return (EXIT_SUCCESS);
}

When I ran this short app, the value of the Pt_ARG_FLAGS
is not changed by PtSetResource. I probably do something
wrong, but I can’t see what or why …

Thanks for any tips/helps/suggestions :slight_smile:

Regards,

jean-louis

Hi Johan,

Thanks for your quick answer :slight_smile:

jean-louis
uhh, from the qnx docs… weird… isn’t it something that the value you get

The example is from the doc, but I added the setting of the flags.

from PtGetResource is a pointer to the real value, so when changing that
value,
the widgets val is updated too? Though the docs is saying you are NOT
supposed to do this on many places…

I don’t know … from what I understand it shouldn’t work that way …
but I may be mistaken

well well, didn’t look very much , but when i set flags, i use
PtSetResource(widget,Pt_ARG_FLAGS,PT_TRUE,Pt_GHOST);
and Pt_FALSE to unset the flag…
That is somewhat easier =)

indeed, but I didn’t know we can do that with PtSetResource … this is a bit
weird as the last argument of it is usualy the length of the data …

I’l try it anyway.

Thanks!

Regards,

jean-louis

Jean-Louis Villecroze wrote:

Howdy,

I’m having some trouble setting the Pt_ARG_FLAGS using
the function PtSetResource (or with PtSetResources) in
the following simple example (from the QNX documentation) :

int main( int argc, char *argv[] )
{
PtWidget_t *window,*widget;
PtArg_t args[1];
long flags;

if ((window = PtAppInit(NULL, &argc, argv, 0, NULL))
== NULL)
PtExit(1);

PtSetArg(&args[0], Pt_ARG_TEXT_STRING,
“hello world”, 0);
widget = PtCreateWidget(PtButton, window, 1, args);
PtRealizeWidget(window);

PtGetResource(widget,Pt_ARG_FLAGS,&flags,0);
printf("%ld\n",flags);

flags |= Pt_GHOST | Pt_BLOCKED;
printf("%ld\n",flags);

PtSetResource(widget,Pt_ARG_FLAGS,flags,0);

PtGetResource(widget,Pt_ARG_FLAGS,&flags,0);
printf("%ld\n",flags);

PtMainLoop();
return (EXIT_SUCCESS);
}

When I ran this short app, the value of the Pt_ARG_FLAGS
is not changed by PtSetResource. I probably do something
wrong, but I can’t see what or why …

Thanks for any tips/helps/suggestions > :slight_smile:

Regards,

jean-louis
uhh, from the qnx docs… weird… isn’t it something that the value you get from PtGetResource is a pointer to the real value, so when changing that value,

the widgets val is updated too? Though the docs is saying you are NOT supposed to do this on many places…
well well, didn’t look very much , but when i set flags, i use
PtSetResource(widget,Pt_ARG_FLAGS,PT_TRUE,Pt_GHOST);
and Pt_FALSE to unset the flag…
That is somewhat easier =)

/Johan

Previously, Jean-Louis Villecroze wrote in qdn.public.qnxrtp.photon:

PtSetResource(widget,Pt_ARG_FLAGS,flags,0);

You have to watch the documentation on PtSetResource() carefully.
The second parameter is a mask which indicates which bits in a
FLAG are to be modified. Below are two routines that set and
un-set the Pt_BLOCKED flag. Hope this helps.


//
/* Block a widget */
/
/
void
widget_set_blocked( PtWidget_t *widget)
{
PtArg_t arg[1];

PtSetArg( &arg[0], Pt_ARG_FLAGS, Pt_BLOCKED, Pt_BLOCKED);
PtSetResources( widget, 1, arg );
}
//
/* UnBlock a widget */
/
/
void
widget_set_unblocked( PtWidget_t *widget)
{
PtArg_t arg[1];

PtSetArg( &arg[0], Pt_ARG_FLAGS, 0, Pt_BLOCKED);
PtSetResources( widget, 1, arg );
}



Mitchell Schoenbrun --------- maschoen@pobox.com

Hello Mitchell,

Thanks a lot for your help. You were right, I overlooked the
this part of the documentation.

Regards,

jean-louis