ID: Q120095
2.5x 2.60 2.60a WINDOWS
The information in this article applies to:
This article explains how to display dialog boxes that do not reside in COMMDLG.DLL.
To display this type of dialog box, you must first create the dialog box with a resource editor. A resource editor allows you to draw a dialog box, add push buttons, edit regions, list boxes, and combo boxes. Once you have done this, you need to compile the resources. Using Visual C++, you can do this seamlessly through App Studio (see the Microsoft Visual C++ "User's Guide").
Once the resources have been compiled, you need to add the .RC file to the project.
The following is a resource file created with Visual C++ App Studio. This resource script will create a dialog box with two edit regions and one push button.
//Microsoft App Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#define APSTUDIO_HIDDEN_SYMBOLS
#include "windows.h"
#undef APSTUDIO_HIDDEN_SYMBOLS
#include "dialogbx.h"
/////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////
// Dialog
//
EXMPDLG DIALOG DISCARDABLE 10, 18, 139, 75
STYLE WS_POPUP | WS_CAPTION
CAPTION "Example Dialog Box"
FONT 10, "Helv"
BEGIN
CTEXT "Title String Here",-1,27,6,78,9,NOT WS_GROUP
EDITTEXT DLI_EDIT1,12,22,26,12
LTEXT "Input field one.",-1,60,24,67,9,NOT WS_GROUP
EDITTEXT DLI_EDIT2,12,37,26,12
LTEXT "Input field two.",-1,60,39,73,10,NOT WS_GROUP
DEFPUSHBUTTON "DONE",DLI_DONE,45,60,36,12
END
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""windows.h""\r\n"
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""dialogbx.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
/////////////////////////////////////////////////////////////////////
#endif // APSTUDIO_INVOKED
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////
// Generated from the TEXTINCLUDE 3 resource.
/////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
To display the dialog box from within the FoxPro Library Construction Kit (LCK), you must first obtain the current instance of the DLL:
HINSTANCE Inst;
Once this is done, you will have the current instance stored in the global
variable Inst.
You must also create a 32-bit pointer to a function because the dialog box must have a dialog box procedure to handle any Windows messages that are sent to the dialog box.
static FARPROC lpfnDialogProc;
You can display the dialog box by making a call to the Windows API
DialogBox() function.
The following C code shows how to call the dialog box:
#include <windows.h>
#include <pro_ext.h>
#define IDM_DOIT 1 // menu item id values
#define IDM_QUIT 2
#define APPNAME "dialogbx"
#define DLI_EDIT1 100
#define DLI_EDIT2 101
#define DLI_DONE 102
// function prototype
BOOL FAR PASCAL DialogProcedure (HWND hDlg, unsigned iMessage, WORD
wParam, LONG lParam) ;
int nEditOne = 0;
int nEditTwo = 0;
HINSTANCE Inst;
static FARPROC lpfnDialogProc;
void dialog(ParamBlk FAR *parm)
{
SetCursor(TRUE);
// This must be done to make the cursor active
lpfnDialogProc = MakeProcInstance (DialogProcedure, Inst) ;
/*The address of the Dialog procedure is stored in
lpfnDialogProc*/
DialogBox (Inst, "exmpdlg", 0, lpfnDialogProc) ;
FreeProcInstance (lpfnDialogProc) ;
}
/*The dialog procedure is used to process any message sent to the
dialog*/
BOOL FAR PASCAL DialogProcedure (HWND hDlg, unsigned iMessage, WORD
wParam, LONG lParam)
{
BOOL bBool ;
switch (iMessage)
{
case WM_INITDIALOG:
SetDlgItemInt (hDlg, DLI_EDIT1, nEditOne, TRUE) ;
SetDlgItemInt (hDlg, DLI_EDIT2, nEditTwo, TRUE) ;
break ;
case WM_COMMAND:
switch (wParam)
{
case DLI_EDIT1:
nEditOne = GetDlgItemInt (hDlg, DLI_EDIT1, &bBool, TRUE);
return (TRUE) ;
case DLI_EDIT2:
nEditTwo = GetDlgItemInt (hDlg, DLI_EDIT2, &bBool, TRUE);
return (TRUE) ;
case DLI_DONE:
EndDialog (hDlg, NULL) ;
return (TRUE) ;
}
break ;
default:
return (FALSE) ;
}
return (FALSE) ;
}
FoxInfo myFoxInfo[]={
{"DIALOG",(FPFI)dialog,0,""},
};
FoxTable _FoxTable=
{
(FoxTable FAR*)0, sizeof(myFoxInfo) / sizeof(FoxInfo), myFoxInfo
};
Microsoft FoxPro Library Construction Kit "Developer's Guide," version 2.5 Microsoft Windows Software Development Kit "Programmer's Reference Volume 2: Functions"
Additional reference words: FoxWin 2.50 2.50a 2.50b 2.60 2.60a lck api KBCategory: KBSubcategory: FxtoolLck
Keywords : kbcode FxtoolLck
Version : 2.5x 2.60 2.60a
Platform : WINDOWS
Last Reviewed: May 22, 1998