From: dan on
What exactly is HTREEITEM? commctrl.h says: "typedef struct _TREEITEM
*HTREEITEM;". Since I'm not getting any compiler error, I assume
"struct _TREEITEM" must be defined somewhere. But I could not find
"struct _TREEITEM" defined in any header file.

I could not find a definition in Microsoft SDK documentation, and
HTREEITEM is not in the index. Petzold and Simon do not list in index.
Rector and Newcomer says it's a handle. But windef.h says
"DECLARE_HANDLE(HWND);", and I don't see the same thing for HTREEITEM.

I saw a few previous postings scratching their heads on this, but no
good answer. Seems like I'm missing something pretty basic. I look
forward to hearing from someone who can you explain HTREEITEM, and how
defined in header files. I use C API, if that matters.

Thanks,
Daniel Goldman

From: Lucian Wischik on
"dan" <dagoldman(a)yahoo.com> wrote:
>What exactly is HTREEITEM? commctrl.h says: "typedef struct _TREEITEM
>*HTREEITEM;". Since I'm not getting any compiler error, I assume
>"struct _TREEITEM" must be defined somewhere. But I could not find
>"struct _TREEITEM" defined in any header file.

I just tried some experiments...

(1)
typedef struct _lucian *HLucian;
HLucian a;

(2)
struct newstructname *varname;

(3)
struct anotherstructname var2name;

Numbers (1) and (2) compile fine in isolation. Number (3) fails with
"var2name uses undefined struct anotherstructname"

So I'd guess that C++ at least lets you define pointers to structs
without defining the struct. And MFC is using it just in the same way
as DECLARE_HANDLE, i.e. to create an opaque handle type.

--
Lucian
From: georges on
"dan" <dagoldman(a)yahoo.com> wrote in message
news:1165610266.086194.254880(a)j44g2000cwa.googlegroups.com...
> What exactly is HTREEITEM? commctrl.h says: "typedef struct _TREEITEM
> *HTREEITEM;". Since I'm not getting any compiler error, I assume
> "struct _TREEITEM" must be defined somewhere. But I could not find
> "struct _TREEITEM" defined in any header file.

It's an internal structure.
You will get its details on MS newsgroups.


From: dan on

Lucian Wischik wrote:
> "dan" <dagoldman(a)yahoo.com> wrote:
> >What exactly is HTREEITEM? commctrl.h says: "typedef struct _TREEITEM
> >*HTREEITEM;". Since I'm not getting any compiler error, I assume
> >"struct _TREEITEM" must be defined somewhere. But I could not find
> >"struct _TREEITEM" defined in any header file.
>
> I just tried some experiments...
>
> (1)
> typedef struct _lucian *HLucian;
> HLucian a;
>
> (2)
> struct newstructname *varname;
>
> (3)
> struct anotherstructname var2name;
>
> Numbers (1) and (2) compile fine in isolation. Number (3) fails with
> "var2name uses undefined struct anotherstructname"
>
> So I'd guess that C++ at least lets you define pointers to structs
> without defining the struct. And MFC is using it just in the same way
> as DECLARE_HANDLE, i.e. to create an opaque handle type.
>
> --
> Lucian

Thanks for doing the experiments. I'm kind of new to Windows, and want
to understand things. I was surprised the MSDN docs did not define
HTREEITEM (at least I couldn't find it).

Is it your opinion that HTREEITEM is a HANDLE like HWND or HDC, which
is simply a number to reference some internal data structure within
Windows?

Maybe there is some historical reason it was defined differently from
other handles, but as far as the programmer is concerned, it's just
another HANDLE?

Thanks,
Daniel

From: Lucian Wischik on
"dan" <dagoldman(a)yahoo.com> wrote:
>Is it your opinion that HTREEITEM is a HANDLE like HWND or HDC, which
>is simply a number to reference some internal data structure within
>Windows?

Yes, I'm sure of it -- I haven't yet seen any exceptions to the rule
"Microsoft uses the prefix "H" to indicate an opaque handle type".

>Maybe there is some historical reason it was defined differently from
>other handles, but as far as the programmer is concerned, it's just
>another HANDLE?

Yes, there must be historical reasons. Isn't HTREEITEM part of MFC
rather than part of win32? I'm didn't even realise that MFC used
opaque handle types until I looked up HTREEITEM in relation to your
problem. Maybe the historical reason is that win32 always uses
DECLARE_HANDLE, but MFC does things its own way.

--
Lucian