Thread: Getting handle of a resource

  1. #1
    Registered User
    Join Date
    Dec 2004
    Posts
    205

    Getting handle of a resource

    Hi,
    I need to get the handle to a resource from a callback function. I am using MDI and I need to be able to know which window the resource is being used in currently. Thanks for any help
    Amish

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    What type of resource?

    Tried GetDlgItem()?

    Could you rephrase the question?
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Registered User
    Join Date
    Dec 2004
    Posts
    205
    The callback function was used with SetTimer. Since the callback function does not belong to any class, I had problem using the window handle passed down to the function to get a handle to a resource item such as a progress bar.
    What happened was before calling SetTimer(...), I would call the CALLBACK function 1 time and set the window handle. It worked the first time around. But then as the program was running, and the function was called at regular time intervals, it seems the window handle address was used for other things by the program and my program would crash miserably when it tried to use the handle. I therefore needed to get a handle to a resource without having to bother in which window the resource would appear. I hope this makes the issue clearer. It's kind of hard to explain. Thanks
    Amish

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    >>I would call the CALLBACK function 1 time and set the window handle.

    DId you use a static or global variable to hold the HWND? (or it may loose scope, not be valid after the function ends)
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  5. #5
    Registered User
    Join Date
    Dec 2004
    Posts
    205
    I use GetSafeHandle() to get the handle to the window. I just pass it as a parameter to the thread function. I don't really store it in any static variable. I can't do that since then every threads will be accessing the same window and I need each thread to access their own window.
    Amish

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sorting out a resource manager
    By psychopath in forum Game Programming
    Replies: 1
    Last Post: 11-10-2008, 07:12 PM
  2. Getting other processes class names
    By Hawkin in forum Windows Programming
    Replies: 3
    Last Post: 03-20-2008, 04:02 PM
  3. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 03:36 AM
  4. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  5. Serial Communications in C
    By ExDigit in forum Windows Programming
    Replies: 7
    Last Post: 01-09-2002, 10:52 AM