News:

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

I have a question about WNDCLASSEX structure.

Started by Snouphruh, December 27, 2005, 05:17:15 AM

Previous topic - Next topic

Snouphruh

Hi!

First, take my congratulations with holiday (the 25 of December :wink) and future close holiday (Happy New Year! :U).
I wanna wish all of you the strong health, a clear mind, bright ideas, a bugs-free code, and maybe happiness and lucky in your own life, business, home.

and now tell me, please, some words about my question.
I meant I wanna know more about cbClsExtra and cbWndExtra members of the structure.
I have read documentation describing that these members reserve "extra" memory for the class and for each window I create. If I'll specify 36 bytes for cbWndExtra member then how will I be able to access those extra bytes.
Documentation says that I can use SetWindowLong for accessing extra bytes. Ok. But I defined 36 bytes and SetWindowLong or GetWindowLong can return only DWORD values as reply.
Can you tell me how to access all of 36 bytes?

Piece and respect, my friends!

P1

Quote from: MSDNIf an application does not use class extra bytes or window extra bytes, it is important that the cbClsExtra and cbWndExtra fields be set to zero.

Class and window extra bytes are a scarce resource. If more than 4 extra bytes are required, use the GlobalAlloc function to allocate a block of memory and store the handle in class or window extra bytes.

Please go this route.

Regards,  P1  :8)

zooba

Especially since the system classes appear to use the extra window bytes for their own purposes (if you aren't subclassing then this won't matter).

In terms of accessing all of the 36 bytes, you have to access a DWORD at a time and isolate it from that. Note that you don't have to access it on 4-byte boundaries - you can GetWindowLong(3) and use AL to read byte 3. (Presumably 4-byte boundaries are more efficient).

My personal preference is to allocate space on a heap and set GWL_USERDATA to be a pointer. This avoids any potential conflict with the system, and if other people are using your controls then they just have to put up with it :-)

hutch--

Snouphruh,

The spec for win9x used to be 40 bytes for the class extra memory. Geting it in DWORD sized bits is not a problem, just chomp it up into smaler pieces if you want to store byte and word values in the extra memory.

With CreateWindowEx() you will not have much problem with the extra memory but you will need to check with dialogs and controls as they use the memory under some conditions. You mainly use the extra memory for stuff that is specific to that particular window and its commonly used in custom controls.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php