Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
BroadcastCommunity.qnx.com will be offline from May 31 6:00pm until June 2 12:00AM for upcoming system upgrades. For more information please go to https://community.qnx.com/sf/discussion/do/listPosts/projects.bazaar/discussion.bazaar.topc28418
Forum Topic - Blocking and Unblocking Widgets: Page 1 of 5 (5 Items)
   
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