[comp.windows.ms.programmer] Modeless Dialogs vs Globals

kevin@msa3b.UUCP (Kevin P. Kleinfelter) (01/08/91)

It appears that the dialog procedure for a modeless dialog cannot
access ANY global data.  This would include literal strings, because
they go into the program's global data area.

For example,
   MessageBox (NULL, (LPSTR) "Literal", NULL, MB_OK);

from within a modeless dialog procedure puts trash in the message box.

However,
   foo [0] = 'O';
   foo [1] = 'K';
   foo [2] = 0;
   MessageBox (NULL, (LPSTR) foo, NULL, MB_OK);

puts OK in a message box.

Am I correct in surmising that global data is inaccessable from a
modeless dialog, and that this includes literal strings?

Is this actually DOCUMENTED somewhere?  Is it appropriate for a
programmer to have to know where his compiler puts literal strings?
-- 
Kevin Kleinfelter @ Dun and Bradstreet Software, Inc (404) 239-2347
{emory,gatech}!nanovx!msa3b!kevin

Soon to become {emory,gatech}!nanovx!dbses0!kevin  (But not yet!)

adonis1@nwnexus.WA.COM (Adonis Corporation ) (01/08/91)

In article <1488@msa3b.UUCP> kevin@msa3b.UUCP (Kevin P. Kleinfelter) writes:
>It appears that the dialog procedure for a modeless dialog cannot
>access ANY global data.  This would include literal strings, because
>they go into the program's global data area.
>   .
>   .
>   .
>   .
>Am I correct in surmising that global data is inaccessable from a
>modeless dialog, and that this includes literal strings?

Boy, I sure don't know where you got this from!  I've been programming 
Windows for a while now and it may be weird, but not that weird.
You can get to globals from anywhere in the program you want to, as long 
as you have an external declaration in the module.  Maybe I missed
something somewhere?


-Doug Kent

jls@hsv3.UUCP (James Seidman) (01/08/91)

In article <1488@msa3b.UUCP> kevin@msa3b.UUCP (Kevin P. Kleinfelter) writes:
>It appears that the dialog procedure for a modeless dialog cannot
>access ANY global data.  This would include literal strings, because
>they go into the program's global data area.
>
>For example,
>   MessageBox (NULL, (LPSTR) "Literal", NULL, MB_OK);

Silly question:  Did you remember to export your dialog procedure?
If not, it's possible that when it gets called the value for DS is
incorrect.

(Incidentally, I can access global data from modeless dialog procedures
without any problem.)

-- 
Jim Seidman (Drax), the accidental engineer.
"It doesn't have to work... they'll be paralyzed just from laughing at me."
							- Dr. Who, _Shada_
UUCP: ames!vsi1!hsv3!jls	         INTERNET: hsv3.UUCP!jls@apple.com