How do I get an hourglass cursor when DBPak is waiting for the database?


Problem

During long database operations I want to have an hour-glass cursor appear.

Solution

The XmNdbBusyCallback on Database Access widgets proovides the information you need to know when to display the busy cursor. All you need is a utility function to do that. The file hourCursor.c contains a routine which will change the cursor on all the top level shells in the application to a large hour-glass.

To hook this up to a Database Access widget, do the following:

    #include "hourCursor.h"
    
    /************************************************************************
     *                                                                      *
     * Busy - our XmNdbBusyCallback handler.   The busy callback is useful  *
     * for setting an hourglass cursor during a DBMS operation.             *
     *                                                                      *
     ************************************************************************/
    
    static void Busy(w, client, call)
            Widget w; XtPointer client; XtPointer call;
    {
            XiDBDataSourceNotifyCallbackStruct *ns =
                            (XiDBDataSourceNotifyCallbackStruct *) call;
    
            /* Verify the reason is right */
            if(ns->reason != XiDB_NOTIFY_BUSY) return;
            /* subreason:   0 for operation over,
             *              non-zero for operation starting
             */
            HourGlass_SetShellCursorHierarchy(AppShell, ns->subreason);
            XSync(XtDisplay(AppShell), False);
    }
    
    
    ... When you create your Database Access widget 
    
            Widget  theDB, parent;
      
            ...
    
            theDB = XtVaCreateWidget("theDB",
                            xiDBSybaseDataSrcWidgetClass, parent,
                            NULL);
    
            /* Track DBMS operations so we can put up an hourglass cursor */
            XtAddCallback(theDB, XmNdbBusyCallback, Busy, (XtPointer) 0);
    
            ...
    
    

hourCursor.c

hourCursor.h

sample.c


HOME Call Us Send Email