Thread overview
A little trick
Aug 23, 2002
Patrick Down
Aug 23, 2002
Pavel Minayev
Aug 25, 2002
Walter
August 23, 2002
Here's a little trick I've used when building
a module for various windows functions that
aren't in Walter's windows.d yet.  A number
of structures in the windows API require the
first member to be a UINT with the structure
size in it.  Which can be initialized in the
structure definition like this.

struct MENUITEMINFO
{
  UINT cbSize = MENUITEMINFO.size;
  UINT fMask;
  UINT fType;
  UINT fState;
  UINT wID;
  HMENU hSubMenu;
  HBITMAP hbmpChecked;
  HBITMAP hbmpUnchecked;
  DWORD dwItemData;
  LPTSTR dwTypeData;
  UINT cch;
  HBITMAP hbmpItem;
}

Ok, it's not much of a trick, but simple
things make me happy. :-)

August 23, 2002
On Fri, 23 Aug 2002 03:20:24 +0000 (UTC) Patrick Down <pat@codemoon.com> wrote:

> 
> Here's a little trick I've used when building
> a module for various windows functions that
> aren't in Walter's windows.d yet.  A number
> of structures in the windows API require the
> first member to be a UINT with the structure
> size in it.  Which can be initialized in the
> structure definition like this.

A neat one! Never really thought of the fact that struct members can be initialized... It is also interesting that it can determine size of the struct before it had even been declared.
August 25, 2002
I love it when neat things like this are discovered!