nanogui: Length of Window extra bytes.


Previous by date: 18 Jan 2000 00:57:14 -0000 Re: Length of Window extra bytes., Chris Johns
Next by date: 18 Jan 2000 00:57:14 -0000 Re: Length of Window extra bytes., Chris Johns
Previous in thread: 18 Jan 2000 00:57:14 -0000 Re: Length of Window extra bytes., Chris Johns
Next in thread: 18 Jan 2000 00:57:14 -0000 Re: Length of Window extra bytes., Chris Johns

Subject: RE: Length of Window extra bytes.
From: Greg Haerr ####@####.####
Date: 18 Jan 2000 00:57:14 -0000
Message-Id: <C1962B36D9BBD311B0F80060083DFEFB041272@SYS.CenSoft.COM>

: Oh. I assumed that the `lpParam' was just not implemented and was to be
: implemented. What is the purpose of the `lpParam' parameter when
: creating a window ?
: 

No, the lpParam parameter to CreateWindowEx is passed as a member
of the CREATESTRUCT structure to the WM_CREATE message, as
are all of parameters to CreateWindowEx.  It's only purpose is to provide
a user-defined parameter from CreateWindowEx to the WM_CREATE
handler.  It is not stored in the window structure.  The application must
save it in window or class extra bytes if required later.



: I cannot use the WM_CREATE message as I do not yet know the relationship
: between the C++ object and hwnd when my WndProc function is called
: (assuming synchronous message sends).

That's OK.  When you do know the relationship, call

	SetWindowLong(hwnd, 0, objectptr);

Then it will be stored with the hwnd.


: 
: I have a single `WndProc' function for all windows created using a
: window class created with the WindowClass class (blah, too many
: classes). In my common WndProc function I need to obtain the object
: pointer so I can call a virtual method `HandleMessage'. This is my per
: window object WndProc function.

Yep, get it with a call to:

	GetWindowLong(hwnd, 0);


: 
: I see in the demo code the `HMENU' window create parameter is really an
: `id' and it is used to handle different windows from within a common
: WndProc function. I would use `id' how-ever is only an `int' and I
: cannot assume the size of int is large enough for a pointer.

You're right.  The hMenu parm is used as an ID for child windows, and
as a menu handle for top level windows.  The correct answer is where
you started: use extra window bytes.  Remember, if the window class
sets the cbWndExtra value non-zero, that many bytes will be allocated
at CreateWindow time.  You can set/get the value anytime afterwards...

Greg

Previous by date: 18 Jan 2000 00:57:14 -0000 Re: Length of Window extra bytes., Chris Johns
Next by date: 18 Jan 2000 00:57:14 -0000 Re: Length of Window extra bytes., Chris Johns
Previous in thread: 18 Jan 2000 00:57:14 -0000 Re: Length of Window extra bytes., Chris Johns
Next in thread: 18 Jan 2000 00:57:14 -0000 Re: Length of Window extra bytes., Chris Johns


Powered by ezmlm-browse 0.20.