Kendall Russell
|
Blocking and Unblocking Widgets
|
Kendall Russell
05/05/2011 12:40 PM
post85447
|
Blocking and Unblocking Widgets
How do you block and unblock individual widgets?
I am attempting to block and unblock (disable and enable) individual widgets depending upon the state of the overall
program and what the user is trying to do.
PtSetResource() is not working for this or I am not calling it correctly. I can successfully get the resource with
PtGetResource().
Right now I am just trying to do this with PtText widgets, but I will soon need to do this with other types as well.
Basically, my code is currently doing the following:
PtGetResource(pWidget, Pt_ARG_FLAGS, &pnGetFlags, 0);
nSetFlags = *pnGetFlags | Pt_BLOCKED;
PtSetResource(pWidget, Pt_ARG_FLAGS, nSetFlags, 0);
//I have also tried the following modifications to PtSetResource
PtSetResource(pWidget, Pt_ARG_FLAGS, nSetFlags, 4);
PtSetResource(pWidget, Pt_ARG_FLAGS, nSetFlags, sizeof(long));
The code for the full functions are included below:
#include <Pt.h>
int WdgtDisable(PtWidget_t* pWidget)
{
int nError = 0;
if(PtWidgetClass(pWidget) == PtText)
{
unsigned long* pnGetFlags = 0;
unsigned long nSetFlags = 0;
/* GET WIDGET FLAGS */
PtGetResource(pWidget, Pt_ARG_FLAGS, &pnGetFlags, 0);
/* SET BLOCK FLAG */
nSetFlags = *pnGetFlags | Pt_BLOCKED;
nError = PtSetResource(pWidget, Pt_ARG_FLAGS, nSetFlags, 4);
/* SET COLOR TO INDICATE WIDGET IS BLOCKED */
PtSetResource(pWidget, Pt_ARG_FILL_COLOR, PgGray(217), 0);
}
return nError;
}
int WdgtEnable(PtWidget_t* pWidget)
{
int nError = 0;
if(PtWidgetClass(pWidget) == PtText)
{
unsigned long* pnGetFlags = 0;
unsigned long nSetFlags = 0;
/* GET WIDGET FLAGS */
PtGetResource(pWidget, Pt_ARG_FLAGS, &pnGetFlags, 0);
/* UNSET BLOCK FLAG */
nSetFlags = *pnGetFlags & ~Pt_BLOCKED;
nError = PtSetResource(pWidget, Pt_ARG_FLAGS, nSetFlags, 4);
/*SET COLOR TO INDICATE WIDGET IS UNBLOCKED*/
PtSetResource(pWidget, Pt_ARG_FILL_COLOR, PgGray(254), 0);
}
return nError;
}
-------
Kendall
|
|
|