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
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
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
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
>>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
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