Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!usc!snorkelwacker!bloom-beacon!athena.mit.edu!warsh From: warsh@athena.mit.edu (Russell Williams) Newsgroups: comp.windows.ms Subject: Re: MessageBox problem Message-ID: <1990Sep10.034812.26521@athena.mit.edu> Date: 10 Sep 90 03:48:12 GMT References: <1990Sep9.224303.10981@bdmrrr.bdm.com> Sender: daemon@athena.mit.edu (Mr Background) Reply-To: warsh@athena.mit.edu (Russell Williams) Organization: MIT Lines: 30 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. Nope, the C compiler will automatically upgrade the near string to an LPSTR since the MessageBox() function is declared using LPSTR arguments. Also, the far address is generated by a push DS, so having a segment moved would not cause things to go wrong (since the instance thunk/function prelude fixes DS when your program is entered) unless your DS is wrong, as can happen mysteriously when you forget to export your dialog function (thus DS will contain the value of whatever data segment was last in use, which may be another program, a DLL, etc). Check that the dialog function is exported. -Russell Williams