Whenever I try to set a resource, I get the error message: "Widget Does Not Allow Resource to be Modified at this Time". What does this mean and how do I work around this?

First, let’s explain why this error message is generated.

When you request BX to set a resource, it sets the resource using the standard XtSetArg routine. It then reads the value of he resource back using the standard XtGetArg function. If the values read back do not match the new values, BX generates the error message "Widget Does Not Allow Resource to be Modified at this Time". Basically, this error message means that the Motif toolkit you are using is not allowing the resource to be set.

In many cases, the situation stems from the fact that you are trying to change the physical dimensions of a child widget where its geometry is actually being overridden by the Parent object. For example, it is very common for this error message to occur when you have parented a XmFrame to an XmForm, set the attachments, and then try to resize directly the XmFrame (we do this in Tutorial 3!). You can get around this in a couple ways. In many cases, it is easiest to grab the user interface with the Window Manager and directly resize the window. In other cases, you will need to unhook the various Attachments, resize as desired, and then reestablish the attachments.

This error message might also be generated in cases where you need to set the values of multiple resources at the same time. For example, in ICS’s EditTable widget, you need to set the number of rows and columns at the same time. You can’t just change the number of columns without setting the number of rows too. It is common for users to try to change the number of columns in the resource editor and receive this error message. Since you cannot change the number of rows and columns simultaneously from within the BX resource editor, you have to apply a different strategy to set the resources appropriately. Basically, you create a "style" that has the number of columns and rows set to the desired value. You then apply this style to your EditTable widget and both rows and columns get set simultaneously and the widget is happy. This strategy can also be applied to other widgets that have similar constraints.

Category: