Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!male!texsun!letni!rwsys!spudge!johnm From: johnm@spudge.UUCP (John Munsch) Newsgroups: comp.windows.ms.programmer Subject: Re: Accessing Dlg Box From WRT Message-ID: <28792@spudge.UUCP> Date: 12 Apr 91 19:20:20 GMT References: <1991Apr11.010030.26145@milton.u.washington.edu> Reply-To: johnm@spudge.UUCP (John Munsch) Organization: Friends of Guru Bob Lines: 40 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 #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