News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

WM_CREATE / CREATESTRUCT.lpCreateParams

Started by Jimg, May 02, 2007, 07:04:10 PM

Previous topic - Next topic

Jimg

is the lpCreateParams value for CREATESTRUCT in the WM_CREATE valid?

I always seem to get a zero, however the other values in the structure seem to contain the correct data.

Or, maybe I'm mis-understanding what the parameter really is???

sinsi

Quote
lpCreateParams
Contains additional data which may be used to create the window. If the window is being created as a result of a call to the CreateWindow or CreateWindowEx function, this member contains the value of the lpParam parameter specified in the function call.
Looks like it's only valid if you use lParam in CreateWindowEx.
Light travels faster than sound, that's why some people seem bright until you hear them.

donkey

Quote from: Jimg on May 02, 2007, 07:04:10 PM
is the lpCreateParams value for CREATESTRUCT in the WM_CREATE valid?

I always seem to get a zero, however the other values in the structure seem to contain the correct data.

Or, maybe I'm mis-understanding what the parameter really is???


Well, if you use CreateWindowEx, it will never be anything but NULL as far as I know, that is because all of the creation data is contained in the API's parameters. However if you use CreateWindow, any additional creation data is pointed to by lpCreateParams, that additional data is simply a copy of what would have been passed if CreateWindowEx had been used. In the case of MDI windows the structures differ slightly.

Donkey
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

zooba

Quote from: Jimg on May 02, 2007, 07:04:10 PM
is the lpCreateParams value for CREATESTRUCT in the WM_CREATE valid?

As sinsi quoted, whatever you pass as lpParam (the last parameter) in CreateWindow or CreateWindowEx will be received as [lParam].CREATESTRUCT.lpCreateParams (of course, you have to move lParam into a register before you can access the structure members, but I'm sure you knew that :wink )

For MDI windows there are specific requirements on what lpParam must be:

Quote from: MSDNIf an application calls CreateWindow to create a MDI client window, lpParam should point to a CLIENTCREATESTRUCT structure. If an MDI client window calls CreateWindow to create an MDI child window, lpParam should point to a MDICREATESTRUCT structure.

So to answer your question, you keep getting a zero because you're passing a zero in the CreateWindow/Ex call.

Cheers,

Zooba :U

xandaz

   Hi again guys. Im having some trouble with something more or less remotelly related to this. I created an mdi client with CLIENTCREATESTRUCT and Children with MDICREATESTRUCT, but, when i process WM_CREATE to create the children damn thing creates and infinite number of children. i don't know if im processing the same creation procedure for everytime WM_CREATE is processed or what?

  did somthing among the lines of this:

   RegisterMdi

xandaz

   Hi again guys. Im having some trouble with something more or less remotelly related to this. I created an mdi client with CLIENTCREATESTRUCT and Children with MDICREATESTRUCT, but, when i process WM_CREATE to create the children damn thing creates and infinite number of children. i don't know if im processing the same creation procedure for everytime WM_CREATE is processed or what?

 did somthing among the lines of this:

  RegisterMdi
 CreateWindowEx,NULL,addr MdiClientClass, addr MdiClientName,Styles, posX,posY,sizeX,SizeY,hWnd,NULL,hInstance,addr ccs
 hMdiClient,eax

; creates this child infinte times :why?
 CreateWindowEx,WS_EX_MDICHILD,addr MdiName,addr MdiChildName,MDIS_ALLCHILDSTYLES,0,0,cx,ly,hMdi,NULL,hInstance,addr mcs
 hMdiChild,eax

Can someone help?
Special thanks guys
best regards xandaz

i have a feeling the solutions is simple but i kind suck at this... for now... byes

Slugsnack

did you register the same wndproc for the child proc and the frame proc ? although the child proc class shouldn't even be registered with a regular wndproc but with a defframeproc

xandaz

   Could you also tell me why :

  mov edi,lParam
  assume edi:PTR CREATESTRUCT
  cmp  [edi].hWndParent,NULL

is different than

  cmp (CREATESTRUCT PTR [lParam]).hWndParent,NULL

???

i was using the second method and it wasnt working because apparentelly hWndParent always returned null and so WM_CREATE was chaining the children creation. When i changed to the first method it stpoed.

Thanks a lot
You guys are great.
Best regrads to the ppl of this great forum

....xandaz


donkey

Not being a MASM user for quite some time I can't really comment on the syntax though from memory they should be equivalent. I would suggest that you fire up Olly and check to see if they are generating different code, that will answer your question.

Donkey
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

zooba

The value of lParam is a pointer to a CREATESTRUCT. This means that you need to take the value of lParam and dereference it:

mov edi, lParam
cmp (CREATESTRUCT PTR [edi]).hWndParent, NULL


lParam is a parameter variable that is textually equivalent (ie. copy-paste) to something like [ebp-4]. So the two sections of code are actually:

mov edi, [ebp-4]
cmp (CREATESTRUCT PTR [edi]).hWndParent, NULL


cmp (CREATESTRUCT PTR [[ebp-4]]).hWndParent, NULL

MASM collapses the multiple sets of square brackets in the second snippet into a single set:

cmp (CREATESTRUCT PTR [ebp-4]).hWndParent, NULL

Which means the first time we are dereferencing ebp-4 twice, but in the second one we only dereference it once. This leaves us staring somewhere in the stack instead of into the structure.

Before you go blaming this odd behaviour on MASM, the fault is partially that the Intel architecture doesn't support double-dereferencing in a single instruction. MASM specifically does not generate more than one instruction for each mnemonic (if you want that, use C) but it should generate a warning for this situation.

Cheers,

Zooba :U

xandaz

    Thanks Zooba. I really appreciate the help. Sorry for late thanks but i've been kinda out.
   
best regards...:
"the now enlightened ( about [edi].hWndParent) xandaz