So Many Variables...

This is a discussion on So Many Variables... within the Windows Programming forums, part of the Platform Specific Boards category; I have been looking through my game programming book and there seem to be so many more types of variable ...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    545

    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
    Posts
    1,342
    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
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    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
    Posts
    8,893
    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!
    CornedBee

    "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
    Posts
    545
    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, 11:02 AM
  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, 10:07 PM
  5. Replies: 6
    Last Post: 01-02-2004, 12:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21