Discussion:
Problem in Using Window handle in UI thread
(too old to reply)
VKumar
2006-02-10 12:05:02 UTC
Permalink
hi

I have a SDI application which has left and right panes. I have secondary UI
thread in this application. Thread class is derived from CWinThread When i
start secondary thread then i pass main window handle to this thread class.
If i want to change left or right pane of window from this thread then i
send a message from this thread to CMainFrame using SendMessage() in which i
pass window handle and it works fine..
I have a dll which contains a function. This function takes window handle as
input. If i use this function in main exe then it works fine. While if i use
this function in thread class then it fails. Since thread has main window
handle and i pass this handle in function of dll but it fails.
Please tell me how to solve thism issue.
Scott McPhillips [MVP]
2006-02-10 13:04:05 UTC
Permalink
Post by VKumar
hi
I have a SDI application which has left and right panes. I have secondary UI
thread in this application. Thread class is derived from CWinThread When i
start secondary thread then i pass main window handle to this thread class.
If i want to change left or right pane of window from this thread then i
send a message from this thread to CMainFrame using SendMessage() in which i
pass window handle and it works fine..
I have a dll which contains a function. This function takes window handle as
input. If i use this function in main exe then it works fine. While if i use
this function in thread class then it fails. Since thread has main window
handle and i pass this handle in function of dll but it fails.
Please tell me how to solve thism issue.
What does the DLL function do with the hwnd, and in what way does it
fail? There are numerous problems using an hwnd from a thread that did
not create the window, because any call except PostMessage becomes a
blocking call that waits for the creating thread to execute the
operation on the window. It is best not to manipulate a window from a
thread that did not create it.
--
Scott McPhillips [VC++ MVP]
Loading...