Discussion:
Problem in Using Window handle in UI thread
(too old to reply)
VKumar
19 years ago
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]
19 years ago
Permalink
...
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...