|
-
Jul 3rd, 2001, 04:05 PM
#1
Thread Starter
PowerPoster
What is the difference between HANDLE and HWND
What is the difference between HANDLE and HWND?
-
Jul 3rd, 2001, 04:12 PM
#2
Monday Morning Lunatic
Technically, not much. Look at the definition for HWND to see how similar all the H* types are. Conceptually, quite a lot is different. I'm not sure if you can pass an HWND to a HANDLE or vice versa but possibly.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jul 3rd, 2001, 04:45 PM
#3
Guru
To elaborate on what parksie said: HANDLE is a handle to any Kernel32 object, while HWND is a handle to a specific User32 object (window).
They're not parts of the same Win32 library, so I would say the chance that you can use a HANDLE value as a HWND and vice versa is pretty, well, tiny
-
Jul 3rd, 2001, 08:58 PM
#4
Thread Starter
PowerPoster
I used handle and hwnd
I used handle on just one time when creating a file.
Everywehre else, for graphics or windws creation, I use hwnd
So is handle used to works with the kernel (files manipulation).
-
Jul 3rd, 2001, 11:47 PM
#5
Im pretty sure that you can pass an HWND as a HANDLE. Someone check the typedefs (I cant at the moment, 16-bit DOS compiler only =( ). I THINK that typedef DWORD HANDLE; and typedef HANDLE HWND; should exist.
Z.
-
Jul 4th, 2001, 05:04 AM
#6
Monday Morning Lunatic
A handle is actually a pointer to a struct, I think.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jul 4th, 2001, 10:37 AM
#7
Guru
Originally posted by parksie
A handle is actually a pointer to a struct, I think.
From what I remember, it goes something like this:
There are two compile modes - STRICT mode and non-STRICT mode. (In VC++ 5, non-STRICT was the default, and in VC++ 6, STRICT was the default.)
In non-STRICT mode, the handles are defined like this:
Code:
typedef void* HANDLE;
typedef void* HWND;
// etc.
In STRICT mode, the handles are defined like this:
Code:
typedef struct __tagHANDLE { DWORD __unused; } *HANDLE;
typedef struct __tagHWND { DWORD __unused; } *HWND;
But I'm not sure... 
Sec, checking.
...
...
...
AHA! There it is, in winnt.h:
Code:
#ifdef STRICT
typedef void *HANDLE;
#define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
#else
typedef PVOID HANDLE;
#define DECLARE_HANDLE(name) typedef HANDLE name
#endif
And in other header files:
Code:
DECLARE_HANDLE(HWND);
DECLARE_HANDLE(HGDIOBJ);
// etc.
Which means the handles are declared like this:
Code:
// STRICT mode:
typedef void* HANDLE;
typedef struct HWND__ { int unused; } *HWND;
typedef struct HGDIOBJ__ { int unused; } *HGDIOBJ;
// etc.
// Non-STRICT mode:
typedef PVOID HANDLE; // PVOID is pretty much the same as void* though
typedef HANDLE HWND;
typedef HANDLE HGDIOBJ;
// etc.
Whew, that was fun
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|