The following procedure is a sample ProcessOnItemHelp() function that would be invoked by choosing On Item from the Help menu.
void ProcessOnItemHelp( Widget widget) { /* Declare a variable for the selected widget. */ Widget selWidget=NULL; int status=DtHELP_SELECT_ERROR; /* Get an application shell widget from our widget hierarchy to * pass into DtHelpReturnSelectedWidgetId(). */ while (!XtIsSubclass(widget, applicationShellWidgetClass)) widget = XtParent(widget); status = DtHelpReturnSelectedWidgetId(widget, NULL, &selWidget); switch ((int)status) { case DtHELP_SELECT_ERROR: printf("Selection Error, cannot continue\n"); break; case DtHELP_SELECT_VALID: /* We have a valid widget selection, now let's look for a registered help * callback to invoke. */ while (selWidget != NULL) { if ((XtHasCallbacks(selWidget, XmNhelpCallback) == XtCallbackHasSome)) { /* Found a help callback, so just call it */ XtCallCallbacks((Widget)selWidget, XmNhelpCallback,NULL); break; } else /* No help callback on current widget, so try the widget's parent */ selWidget = XtParent(selWidget); } break; case DtHELP_SELECT_ABORT: printf("Selection Aborted by user.\n"); break; case DtHELP_SELECT_INVALID: printf("You must select a component within your app.\n"); break; } }