home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / os / os2 / programm / 6403 < prev    next >
Encoding:
Text File  |  1992-11-14  |  2.3 KB  |  51 lines

  1. Newsgroups: comp.os.os2.programmer
  2. Path: sparky!uunet!ornl!rsg1.er.usgs.gov!darwin.sura.net!zaphod.mps.ohio-state.edu!malgudi.oar.net!news.ans.net!cmcl2!panix!os2man
  3. From: os2man@panix.com (Larry Salomon Jr.)
  4. Subject: Re: WinCreateWindow(...pCtlData,..) -> WM_CREATE problem
  5. Message-ID: <1992Nov13.134326.17247@panix.com>
  6. Date: Fri, 13 Nov 1992 13:43:26 GMT
  7. References: <721564770fred.fred@oneup.gwinnett.com> <721566380fred.fred@oneup.gwinnett.com>
  8. Organization: PANIX Public Access Unix, NYC
  9. Lines: 40
  10.  
  11. In <721566380fred.fred@oneup.gwinnett.com> fred@oneup.gwinnett.com (Fred Christianson) writes:
  12.  
  13. >I've had this happen in 3 programs I've writen, and now a coworker
  14. >just found it happening in his program.
  15.  
  16. >I do a WinCreateWindow() and have the pCtlData parameter pointing
  17. >to an initialization structure.  When the window procedure gets
  18. >a WM_CREATE message, mp1 is supposed to have the pCtlData pointer, and
  19. >most of the time it does.  
  20.  
  21. >But, about 1 in 5-10 times mp1 is not the same as the pointer I had in
  22. >WinCreateWindow().  Sometimes it has been 16 bytes off of the correct
  23. >pointer, but other times it looks nothing like the origional.  
  24.  
  25. >I've tried having pCtlData point to a local, a global, and a malloc()'ed
  26. >structure, and they all do the same things.  
  27.  
  28. Funny thing happened to me while porting my application to 32-bit (using
  29. C Set/2) yesterday...
  30.  
  31. I was talking to a friend of mine (who, incidentally, helped me overcome
  32. the "global vars getting clobbered" problem.  My compiler options were
  33. goofy.) who mentioned that it is a little known by widely seen problem
  34. that any structures passed to WM_CREATE or WM_INITDLG (via the create
  35. params) *need* to have as their first field a USHORT containing the
  36. size of the structure.  This is because PM does a *lot* of thunking 
  37. behind the scenes and it needs to know how many bytes the structure
  38. is.
  39.  
  40. Yes, I realize that the explanation for this is hokey.  However, he did
  41. say that when he did that, his problems went away.  Even if it is hard
  42. to believe, do it anyways.  What's one extra USHORT?  You've got nothing
  43. to lose and everything to gain, eh?
  44.  
  45. Cheers,
  46. Q
  47. -- 
  48. "If you choose not to decide, you  | "A fool and his money are fun to go
  49.  still have made a choice" - Rush  |  out with" - seen on a T-shirt
  50. ------------------------------------------------------------------------
  51.