Windows - HDC
BlitzMax Forums/BlitzMax Programming/Windows - HDC
| ||
Hallo, Just looking through the Pub.Win32 stuff. Is HDC a pointer or an "Int" (as defined in all the externs). :o) |
| ||
You might find this useful -- a list of what Win32 data types actually are. HDC is apparently a HANDLE, which it says is typedef PVOID HANDLE. Not even sure what that is... |
| ||
Cool. Thanks. So not much work to do then... :-/ |
| ||
I tried to explain it, but I am exhausted and it wasn't making sense to me and I understand it. This probably explains it best and better than I can: es and no ... YES, you can have a pointer to an HDC or an Hanything (HWND, etc) ... and dereference it like you want to ... but there is no point. For 1, if HDC was a typedef for a pointer type ... then you could just declare: HDC bitmap; and assign to it ... there would be very few reasons to use an aditional pointer layer ... but the H types are NOT pointers ... they are indexes ... in other words simple integers ... which of course are USED by windows as lookups into tables ... but the point being, you treat them like integral types, just assign to them and compare them for equality as if they were any other form of index or iterator (or even pointer of course) ... all of microsofts Handle types are also compatible with each other ... ie, identical types ... although I''ve been told that in STRICT mode, they do use pointer typedefs just to allow the compiler to warn you when you mix them ... http://www.gamedev.net/topic/148985-pointer-to-an-hdc/ |
| ||
Thanks. So on 64-bit, it becomes an 8-byte integral type, which is not the same as an Int, unfortunately. |
| ||
It depends on what compiler you use. MSVC++ uses the LLP64 model, so ints and longs are 32-bits in 64-bit mode. GCC uses the LP64 model, so ints are 32-bits and longs are 64-bits in 64-bit mode. Intel's compiler info is here: https://software.intel.com/en-us/articles/size-of-long-integer-type-on-different-architecture-and-os However, the compiler merely sets limits, the number of bytes and range of values is ultimately determined by the CPU's architecture. |
| ||
HDC is apparently a HANDLE, which it says is typedef PVOID HANDLE. Not even sure what that is... That means all handles are the same as void pointers, which are quite the opposite of integral types (and non void pointers) in that you can't do arithmetic operations on them. |
| ||
No eggs without DRM |
| ||
On x64 Windows most handles are just sign extended and can be stored in 32 bit ints. http://msdn.microsoft.com/en-us/library/windows/desktop/ee872017(v=vs.85).aspx http://stackoverflow.com/questions/18266626/what-is-windows-handle-range-on-a-64-bits-application |
| ||
On x64 Windows most handles are just sign extended and can be stored in 32 bit ints. Given that some programming languages do not even support pointers, you often don't have a choice when dealing with handles. |
| ||
H = Handle DC = Device Context HDC = Handle to the Device Context structure WND = Window HWND = Handle to the Window structure handles should start off as null/void You then associate then with GetWindow(), GetHandle(), etc (win32) P = Pointer PVOID = Pointer (if valid) or Void Beware, when using windows pointers make sure that are still valid and not become void or you will get a crash. |