home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windoware
/
WINDOWARE_1_6.iso
/
source
/
adg_1-3
/
dlg-mdls.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-02-21
|
4KB
|
128 lines
/****************************************************************************
Module name: Dlg-Mdls.C
Programmer : Jeffrey M. Richter.
*****************************************************************************/
#include "..\nowindws.h"
#undef NOCOLOR
#undef NOCTLMGR
#undef NOKERNEL
#undef NOMSG
#undef NOSHOWWINDOW
#undef NOUSER
#undef NOWINMESSAGES
#undef NOWINOFFSETS
#undef NOWINSTYLES
#include <windows.h>
#include "dlg-mdls.h"
static char _szModalLessResult[] = "ModalLessResult";
HWND FAR PASCAL CreateModalLessDlgBox (HANDLE hInstance, LPSTR szTemplateName,
HWND hWndParent, FARPROC DialogFunc, DWORD lInitParam) {
return(CreateDialogParam(hInstance, szTemplateName,
hWndParent, DialogFunc, lInitParam));
}
BOOL FAR PASCAL DestroyModalLessDlgBox (HWND hDlg) {
return(DestroyWindow(hDlg));
}
int FAR PASCAL ModalLessDlgBox (HWND hDlg, HWND hWndParent, LONG lParam) {
BOOL fPropFound = FALSE;
int nResult = NULL, nModalLessShowMsg;
MSG msg;
EnableWindow(hWndParent, FALSE);
// Register and send the "ModalLessShowMsg" msg to the ModalLess Dlg Box.
nModalLessShowMsg = RegisterWindowMessage(SZMODALLESSSHOWMSG);
SendMessage(hDlg, nModalLessShowMsg, 0, lParam);
// Display the modalless dialog box.
ShowWindow(hDlg, SW_SHOW);
// Continue the message loop until the "ModalLessResult" property has been
// associated with the modalless dialog box. This happens when the
// dialog box function calls the EndModalLessDlgBox function.
while (!fPropFound) {
GetMessage(&msg, NULL, 0, 0);
if (!IsDialogMessage(hDlg, &msg)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
// Get value of "ModalLessResult" property. If property does not
// exist, GetProp returns zero.
nResult = GetProp(hDlg, _szModalLessResult);
// Try to remove the property. If RemoveProp returns NULL, the
// property was never associated with the window and the message
// loop must continue.
fPropFound = RemoveProp(hDlg, _szModalLessResult) != NULL;
}
EnableWindow(hWndParent, TRUE);
// Hide the modalless dialog box and return the result to the application.
ShowWindow(hDlg, SW_HIDE);
return(nResult);
}
BOOL FAR PASCAL EndModalLessDlgBox (HWND hDlg, int nResult) {
return(SetProp(hDlg, _szModalLessResult, nResult));
}
#ifdef _DEMO
//****************************************************************************
// Functions for the ModalLess Dialog Box Demonstration.
#include "dialog.h"
BOOL FAR PASCAL ModalLessDlgProc (HWND hDlg, WORD wMsg, WORD wParam, LONG lParam) {
BOOL fProcessed = TRUE;
if (wMsg == RegisterWindowMessage(SZMODALLESSSHOWMSG)) {
// Initialize the "EDIT" window with some text whenever the dialog box
// is about to be shown.
SetDlgItemText(hDlg, ID_NAME, "Default text");
// Make the "EDIT" window have the focus.
SetFocus(GetDlgItem(hDlg, ID_NAME));
}
switch (wMsg) {
case WM_INITDIALOG:
break;
case WM_COMMAND:
switch (wParam) {
case IDOK:
case IDCANCEL:
if (HIWORD(lParam) == BN_CLICKED)
EndModalLessDlgBox(hDlg, wParam);
break;
default:
break;
}
break;
default:
fProcessed = FALSE;
break;
}
return(fProcessed);
}
#endif