Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!otter.hpl.hp.com!otter!hdg From: hdg@otter.hpl.hp.com (Hugh Duggan) Newsgroups: comp.windows.ms.programmer Subject: Re: Strange clobberings. Message-ID: <72170013@otter.hpl.hp.com> Date: 12 Jun 91 08:08:36 GMT References: <1991Jun11.210451.14087@athena.mit.edu> Organization: Hewlett-Packard Laboratories, Bristol, UK. Lines: 34 > > I am trying to call MessageBox() from a Dialog Box. If I call > it with MB(hDlg, (LPSTR) "No filename specified", NULL, MB...); > > the string is not displayed, and junk is in it's place, and memory > is cold screwed up. > > If I call it with a string used elsewhere in the program, defined at the > top as: > static char DefSpec[10] = "*.*"; > > It works. > > But if I define my own: > static char Err[100] = "Yo mama"; > > I get the same error. > > Any clues?????? > ---------- Your dialogue box function is being called by Windows, not directly by any code you have written. Consequently, you cannot guarantee to have the correct data segment loaded (it is just chance that your second example worked- in the other cases, Windows has loaded its own data segment). Solution: make sure that the dialogue box function is declared with the _loadds keyword, or compile your code with a switch which forces DS to be reloaded on entry to all functions. This problem will be seen whenever you try to use any static or global data (ie allocated from the heap) within a callback function. Hugh Duggan HP Labs, Bristol