Question?

This is a discussion on Question? within the Windows Programming forums, part of the Platform Specific Boards category; what's hwnd ? what's hinstance? and what difference between them?...

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    30

    Question?

    what's hwnd ?
    what's hinstance?
    and what difference between them?

  2. #2
    Registered User Esss's Avatar
    Join Date
    Aug 2001
    Posts
    133
    > what's hwnd ?

    A handle to a window.

    > what's hinstance?

    A handle to the running instance of a program.

    > and what difference between them?

    What's the difference between apples and pears?
    Ess
    Like a rat in a maze who says,
    "Watch me choose my own direction"
    Are you under the illusion
    The path is winding your way?
    - Rush

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    30

    specify

    i dont understand could you be more specify?

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    Just think of it like this;


    hwnd is a common implementation of the type HWND (as described in windows.h) that gives a handle to a window. It is used to identify and work with specific windows be they dialog boxes, main windows or controls (all of these are technically windows). So when you want to do something specific with a window, you will address it through hwnd.

    hinstance is of the type HINSTANCE and is passed to your program by the operating system via WinMain. This represents the "instance" of your program when it runs. With Windows (the operating system) you can often have multiple copies of your program running at once. Picture this as a specific identifier for your program while itís running. You need this variable for a whole host of functions, for instance if you use CreateWindow() you will need to pass hinstance to create a window. Incidentally this specific function will then give you a hwnd.

    To really learn more you should get Programming Windows by Charles Petzold

  5. #5
    Registered User
    Join Date
    Aug 2001
    Posts
    30
    so hinstance is a handle to my window and hwnd is a handle to other windows?

  6. #6
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    >>so hinstance is a handle to my window and hwnd is a handle to other windows?

    No it relates to the whole program.

    See Petzold

  7. #7
    Registered User
    Join Date
    Aug 2001
    Posts
    30
    hwnd and hinstance are a handle to my window so are the same?

  8. #8
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    You misunderstood. Like Fordy said, since Windows can have more than one copy of your program running, hinstance is a handle to the instance of your program. Sort of an identifier for your program.

    hwnd is just a handle to a window.

  9. #9
    Registered User
    Join Date
    Aug 2001
    Posts
    30
    so hwnd is a handle to my window and hinstance is handle to all the program

    and how the SetTimer() function work every how much time i tell it to work without a loop?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 12:47 AM

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