I am talking about a Windows desktop application. I am looking to write a function such as SelectObject
(for example) which blocks the caller till the user clicks on an object in the application's client area. Once the user has selected an object, the function returns a pointer to it.
One way to do this is to run a small message loop and filter out WM_MOUSE*
while passing other messages back to the outer message loop. (CRectTracker
does this I think.)
This could also be redesigned to run the caller in a separate thread of it's own. SelectObject
will then use CreateEvent/SetEvent/ResetEvent
to synchronize with the main thread which handles the mouse messages and returns control once the conditions satisfying object selection are met.
What are the pros and cons of each approach? Where can I find more information on such designs? What are the formal terms for such things?
Programmers who have closely observed or worked with AutoCAD may understand what I have so badly conveyed here.