🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.os2.programmer
Article #1896

Re: WinCreateWindow(...pCtlData,..) -> WM_CREATE problem

#1896
From: Larry Salomon Jr.
Date: Fri, 13 Nov 1992 13:43
40 lines
2398 bytes
In <721566380fred.fred@oneup.gwinnett.com> fred@oneup.gwinnett.com (Fred Christianson) writes:

>I've had this happen in 3 programs I've writen, and now a coworker
>just found it happening in his program.

>I do a WinCreateWindow() and have the pCtlData parameter pointing
>to an initialization structure.  When the window procedure gets
>a WM_CREATE message, mp1 is supposed to have the pCtlData pointer, and
>most of the time it does.  

>But, about 1 in 5-10 times mp1 is not the same as the pointer I had in
>WinCreateWindow().  Sometimes it has been 16 bytes off of the correct
>pointer, but other times it looks nothing like the origional.  

>I've tried having pCtlData point to a local, a global, and a malloc()'ed
>structure, and they all do the same things.  

Funny thing happened to me while porting my application to 32-bit (using
C Set/2) yesterday...

I was talking to a friend of mine (who, incidentally, helped me overcome
the "global vars getting clobbered" problem.  My compiler options were
goofy.) who mentioned that it is a little known by widely seen problem
that any structures passed to WM_CREATE or WM_INITDLG (via the create
params) *need* to have as their first field a USHORT containing the
size of the structure.  This is because PM does a *lot* of thunking 
behind the scenes and it needs to know how many bytes the structure
is.

Yes, I realize that the explanation for this is hokey.  However, he did
say that when he did that, his problems went away.  Even if it is hard
to believe, do it anyways.  What's one extra USHORT?  You've got nothing
to lose and everything to gain, eh?

Cheers,
Q
-- 
"If you choose not to decide, you  | "A fool and his money are fun to go
 still have made a choice" - Rush  |  out with" - seen on a T-shirt
------------------------------------------------------------------------
Technical Details
Message-ID: <1992Nov13.134326.17247@panix.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!ornl!rsg1.er.usgs.gov!darwin.sura.net!zaphod.mps.ohio-state.edu!malgudi.oar.net!news.ans.net!cmcl2!panix!os2man
References: <721564770fred.fred@oneup.gwinnett.com> <721566380fred.fred@oneup.gwinnett.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.os.os2.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!ornl!rsg1.er.usgs.gov!darwin.sura.net!zaphod.mps.ohio-state.edu!malgudi.oar.net!news.ans.net!cmcl2!panix!os2man
From: os2man@panix.com (Larry Salomon Jr.)
Subject: Re: WinCreateWindow(...pCtlData,..) -> WM_CREATE problem
Message-ID: <1992Nov13.134326.17247@panix.com>
Date: Fri, 13 Nov 1992 13:43:26 GMT
References: <721564770fred.fred@oneup.gwinnett.com> <721566380fred.fred@oneup.gwinnett.com>
Organization: PANIX Public Access Unix, NYC
Lines: 40