Thread: So Many Variables...

  1. #1
    Registered User
    Join Date
    Nov 2005

    So Many Variables...

    I have been looking through my game programming book and there seem to be so many more types of variable (if that is the right word). HINSTANCE, HDC, DWORD, UINT, RECT. I was wondering if people could explain these.

  2. #2
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    HINSTANCE: A program's handle used for things like resources.
    HDC: A handle used for drawing images and text.
    DWORD: A 24-bit varible. (Example: 0x000000)
    UINT: I don't really know any difference between this and int.
    RECT: A struct with 4 ints, used as regions.

  3. #3
    Join Date
    Jan 2002
    Most of them are typdef'd in windef.h and basetsd.h; a quick glance of those and a few other headers should tell you what types they are aliases for. For structures, such as RECT, msdn has specific documentation. Those that start with an 'H' are handles - like HINSTANCE handle to an instance (actually a starting address in memory), HDC - handle to a device context and so on.

    Usually the types are described as parameters of winapi functions and you can usually get much more information about them within that context.

    For completeness, UINT is unsigned int and DWORD (double word) is also an unsigned int alias.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    DWORD is a type guaranteed to be 32 bits wide and unsigned integral.
    UINT is guaranteed to be unsigned integral, but I don't think it has any width guarantees.

    HINSTANCE is more or less a relic of 16-bit Windows programming. It's also synonymous with HMODULE, which is a handle to a specific program module (the main EXE or any DLL) in your address space.

    HDC is a handle to a device context, an abstraction of an output device such as a screen (region) or a printer, though it could also refer to a memory region or any other virtual or concrete device that supports raster operations somehow.
    All the buzzt!

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  5. #5
    Registered User
    Join Date
    Nov 2005
    Thanks, I think I get the code that my book throws at me, apart from why he uses all these things like returning HINSTANCES etc. It seems very complicated.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. basic question about global variables
    By radeberger in forum C++ Programming
    Replies: 0
    Last Post: 04-06-2009, 12:54 AM
  2. Best way to avoid using global variables
    By Canadian0469 in forum C++ Programming
    Replies: 7
    Last Post: 12-18-2008, 12:02 PM
  3. Replies: 15
    Last Post: 09-30-2008, 02:12 AM
  4. esbo's data sharing example
    By esbo in forum C Programming
    Replies: 49
    Last Post: 01-08-2008, 11:07 PM
  5. Replies: 6
    Last Post: 01-02-2004, 01:01 PM