Share via


_Dialog( ) API Library Routine

Displays on the screen a dialog box that is the specified color scheme and contains the specified body text and button text.

int _Dialog(int scheme, char FAR *body_text, char FAR *button1, 
            char FAR *button2, char FAR *button3, int default, int
 escape)
int scheme;                  /* Color scheme number. */
char FAR *body_text;         /* Text in dialog. */
char FAR *button1;         /* Button prompt. */
char FAR *button2;         /* Button prompt. */
char FAR *button3;         /* Button prompt. */
int default;                  /* Number of the default button. */
int escape;                  /* Number of the button to press if Esc. */

Remarks

_Dialog( ) returns the number of the button the user chooses.

To specify fewer than three buttons for the displayed dialog box, specify 0 as a button prompt to leave any of the three buttons blank. The default parameter specifies which button to highlight in the dialog box as the default button, and the escape parameter specifies which button to process as chosen if the user presses ESC.

If you specify no buttons, Visual FoxPro displays the dialog box and waits for the user to press a key or click the left mouse button. If the user presses Esc, _Dialog( ) returns the escape value; otherwise, it returns the default value.

For more information on how to create an API library and integrate it with Visual FoxPro, see Accessing the Visual FoxPro API.

Example

The following example creates four dialog boxes with three, two, one, and no buttons.

Visual FoxPro Code

SET LIBRARY TO DIALOG  

C Code

#include <pro_ext.h>

void putLong(long n)
{
   Value val;

   val.ev_type = 'I';
   val.ev_long = n;
   val.ev_width = 10;

   _PutValue(&val);
}

void FAR dialogEx(ParamBlk FAR *parm)
{
   int selection;

   selection = _Dialog(DIALOG_SCHEME, "Example dialog with 3 buttons.",
      "First", "Second", "Third", 2, 3);

   _PutStr("\nItem selected ="); putLong(selection);

   selection = _Dialog(DIALOG_SCHEME, "Example dialog with 2 buttons.",
      "First", "Second", 0, 2, 2);

   _PutStr("\nItem selected ="); putLong(selection);

   selection = _Dialog(DIALOG_SCHEME, "Example dialog with 1 button.",
      "First", (char *)0, (char *)0, 1, 1);

   _PutStr("\nItem selected ="); putLong(selection);

   selection = _Dialog(DIALOG_SCHEME, "Example dialog no buttons.",
      (char *)0, (char *)0, (char *)0, 1, 2);

   _PutStr("\nItem selected ="); putLong(selection);
}

FoxInfo myFoxInfo[] = {
   {"DIALOGEX", (FPFI) dialogEx, CALLONLOAD, ""},
};
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};

See Also

Accessing the Visual FoxPro API | SET LIBRARY Command