bytor@milton.u.washington.edu (Jill Patterson) (04/11/91)
I'm trying to bring up a Dialog Box, such as the About1 Dialog Box in Petzold's Book. I am using BC++ and WRT. I have created a Dialog Box using the Whitewater Resource Toolkit and have given it the name DLG_ABOUT. My question is this how do I bring up the dialog box. I have something like the following case IDM_ABOUT : DialogBox(hInstance, "DLG_ABOUT", hwnd, lpfnAboutDlgProc); return 0; This Code Is the same as that found on page 406 of the Petzold book. If anybody could send me some sample code on how to call I Dialog Created from WRT I sure would appreciate it. Or perhaps I missed something in the manual? Whenever I select the About Menu Item I get a Unrecoverable Application Error. THX bytor@milton.u.washington.edu
johnm@spudge.UUCP (John Munsch) (04/13/91)
In article <1991Apr11.010030.26145@milton.u.washington.edu> bytor@milton.u.washington.edu (Jill Patterson) writes: > > I'm trying to bring up a Dialog Box, such as the About1 Dialog Box >in Petzold's Book. I am using BC++ and WRT. I have created a Dialog Box >using the Whitewater Resource Toolkit and have given it the name DLG_ABOUT. >My question is this how do I bring up the dialog box. I have something like >the following > > case IDM_ABOUT : > DialogBox(hInstance, "DLG_ABOUT", hwnd, lpfnAboutDlgProc); > return 0; > > This Code Is the same as that found on page 406 of the Petzold book. You did use the code from his WM_CREATE case just above that didn't you? If not, you're problem is that you haven't done a MakeProcInstance() on the function that you intend to call. Here's a function that I usually use to do all the dialog box stuff encapsulated into one function. // dialog.cpp // tab_size: 4 #include <windows.h> #include "winsupp.h" // Just a prototype... BOOL Dialog(HWND hWnd, char *szDialogName, FARPROC fpDialogProc) { BOOL bDBReturn; HANDLE hInst; FARPROC fpProc; hInst = GetWindowWord(hWnd, GWW_HINSTANCE); fpProc = MakeProcInstance(fpDialogProc, hInst); bDBReturn = DialogBox(hInst, szDialogName, hWnd, fpProc); FreeProcInstance(fpProc); return (bDBReturn); } John Munsch