Path: utzoo!utgpu!watserv1!watmath!att!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!jarthur!uunet!world!goodearl From: goodearl@world.std.com (Robert Goodearl) Newsgroups: comp.windows.ms Subject: Re: MessageBox problem Message-ID: <1990Sep10.145355.4862@world.std.com> Date: 10 Sep 90 14:53:55 GMT References: <1990Sep9.224303.10981@bdmrrr.bdm.com> Organization: The World Lines: 31 In article <1990Sep9.224303.10981@bdmrrr.bdm.com> davis@bdmrrr.bdm.com (Arthur Davis x4675) writes: >Someone mentioned having a problem with garbled strings in a >MessageBox call; i.e. MessageBox (hDlg, "abc", "xyz", MB_OK) >produces garbage on the display. > >Unless you are working in large model (which you shouldn't be >without VERY good reasons), quoted string literals are certain >to be passed as near addresses. The declaration of the string >parameters in the MessageBox function is LPSTR, or the long >address of string. What is happening to you I guess is that >Windows is moving your segment around and the near addresses of >your strings is becoming invalid, leaving you with screen crud. > >Try this: > >MessageBox (hDlg, (LPSTR) "abc", (LPSTR) "xyz", MB_OK); > >This will force the pass of a FAR or long address and should solve your >problem. Using the LPSTR cast will not solve the problem of moving segments. It will insure that you pass a far pointer, but if you have included the file windows.h in your source, you will not need to cast as the function prototype included there will take care of that problem for you. If you are passing literal strings to message box, they are in your local data segment. If your data segment is marked as moveable, you may need to lock it down before calling message box. Reference the function LockData on p 4-293 of the sdk. -- Bob Goodearl -- goodearl@world.std.com