Last time, we saw an example of code that was UI-modal but not code-modal. The opposite is also true: You can have code-modality without UI-modality. In fact, this is far more common than the UI-modal-but-not-code-modal scenario.
You encounter modal loops without a visible change in UI state when you drag the scroll bar thumb, drag the window caption, display a pop-up menu, or initiate an OLE drag/drop operation, among other places. Any time a nested message loop is constructed, you have code modality.
One example is given in MSDN, where the MsgWaitForMultipleObjects
function is used to construct a message loop without any modal UI. (We discussed some of the gotchas of the MsgWaitForMultipleObjects
function in an earlier entry.)
February 21st, 2005
Modality, part 2: Code-modality vs UI-modality
Category
Author
Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.
0 comments