Skip to main content
GameDev.net gamedev.net
🔒 Locked

lpCreateParams

Started by walkingcarcass Jul 13, 2004 at 11:08 AM 4 replies 3.3k views
Original Post
walkingcarcass
walkingcarcass
For the first time, I've come into the situation where I need to send some data to a window as it is created, it seems to be that putting a pointer in lpParam in CreateWindowEx is the sensible way, and that I can get this number from the lpCreateParams member of CREATESTRUCT, right? It's just that the Windows NT remarks confuse me a bit, when I read the description
Quote:
This member is the address of a SHORT (16_bit) value that specifies the size, in bytes, of the window creation data. The value is immediately followed by the creation data.
It seems to me that this means if x==lpParam under Win9x then x==*(lpParam+2) under windows NT, but the code example in the docs seems a little odd

typedef struct tagMyData { 
    . . .;	// define creation data here 
} MYDATA; 
 
typedef struct tagMyDlgData { 
    SHORT    cbExtra; 
    MYDATA  myData; 
} MYDLGDATA, UNALIGNED *PMYDLGDATA; 
 
PMYDLGDATA pMyDlgdata = 
    (PMYDLGDATA) (((LPCREATESTRUCT) lParam)->lpcreateParams);


Is x==myData? The size of the structure seems odd, and what the hell does the unaligned thing do? Does this happen under any other versions of Windows? Thanks
spraff.net: don't laugh, I'm still just starting...
SiCrane
SiCrane
It might help if you read the entire sentence instead of starting in the middle. (Either that or your copy of the MSDN needs to be updated.) The actual sentence goes:
Quote:
If the window is being created from a dialog template, this member is the address of a SHORT value that specifies the size, in bytes, of the window creation data. The value is immediately followed by the creation data.


If the window is created through a dialog template under any of the NT based Windows versions, then the creation parameters are preceded by a SHORT that describes the length of the creation parameter field. This is done to allow versioning of dialog classes. For example, a later version of a dialog might put additional flags at the end of the creation structure. If it's not created through a dialog template then you don't have to worry about it.

I have no idea what you mean by your x==lpParam notation. What is x supposed to be?

In any case, the UNALIGNED macro is meant to be a hint that a pointer address received through a UNALIGNED pointer may not be DWORD aligned, in fact, probably won't be. Depending on your preprocesser flags UNALIGNED may expand to the __unaligned keyword.
psae0001
psae0001
Well, the last thread proves that I'm not a HTML guy!!!
I'll just copy and paste the URL for you here--don't click on the last thread!

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/Windowing/Windows/WindowReference/WindowStructures/CREATESTRUCT.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/Windowing/Windows/WindowReference/WindowMessages/WM_NCCREATE.asp
Aprosenf
Aprosenf
Storing a CREATESTRUCT pointer in a static variable is a VERY BAD idea. Who's to say Windows didn't make a CREATESTRUCT on the stack, pass it to your message handler, and pop it off the stack once you've processed the message? If you're going to take that route, store the value of lpCreateParams in a static variable, not the value of lparam.
Empirical
Empirical
Quote:
Original post by psae0001
Well, the last thread proves that I'm not a HTML guy!!!
I'll just copy and paste the URL for you here--don't click on the last thread!

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/Windowing/Windows/WindowReference/WindowStructures/CREATESTRUCT.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/Windowing/Windows/WindowReference/WindowMessages/WM_NCCREATE.asp


You were close, you just have to remeber to add < / a > (less spaces) at the end of the url.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.