User Tools

Site Tools


replacing_20the_20message_20pump

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
replacing_20the_20message_20pump [2018/04/13 11:48]
richardrussell
replacing_20the_20message_20pump [2018/04/17 18:32] (current)
tbest3112 Added syntax highlighting for c
Line 2: Line 2:
  
 //by Richard Russell, January 2012//\\ \\  In Windows, every User Interface (UI) thread must have a [[http://​en.wikipedia.org/​wiki/​Message_loop_in_Microsoft_Windows|message pump]] (or message loop), the function of which is to serialise and dispatch incoming messages to their destination windows. \\ \\  In //BBC BASIC for Windows// the message pump is provided by the Run Time Engine, and generally the programmer doesn'​t need to be aware of it. For anybody who may be interested, this is its C code:​\\ ​ //by Richard Russell, January 2012//\\ \\  In Windows, every User Interface (UI) thread must have a [[http://​en.wikipedia.org/​wiki/​Message_loop_in_Microsoft_Windows|message pump]] (or message loop), the function of which is to serialise and dispatch incoming messages to their destination windows. \\ \\  In //BBC BASIC for Windows// the message pump is provided by the Run Time Engine, and generally the programmer doesn'​t need to be aware of it. For anybody who may be interested, this is its C code:​\\ ​
 +<code c>
   while (GetMessage (&msg, NULL, 0, 0) != FALSE )   while (GetMessage (&msg, NULL, 0, 0) != FALSE )
        {        {
Line 13: Line 14:
            }            }
        }        }
 +</​code>​
 Very occasionally there may be a requirement to use a different message pump. For example, in order for **keyboard navigation** to work in a dialogue box, the message pump must include a call to the [[http://​msdn.microsoft.com/​en-us/​library/​windows/​desktop/​ms645498(v=vs.85).aspx|IsDialogMessage]] API.\\ \\  Until very recently I believed that it was impossible to //replace// the existing BB4W message pump, and that therefore the only way to provide a different one was to start a new thread (each thread has its own message pump). This is the principal reason why the **WINLIB2** library creates a new thread for every new dialogue box created.\\ \\  However I have discovered that in fact there is a way of replacing the '​main'​ message pump, and the procedure listed below does exactly that: Very occasionally there may be a requirement to use a different message pump. For example, in order for **keyboard navigation** to work in a dialogue box, the message pump must include a call to the [[http://​msdn.microsoft.com/​en-us/​library/​windows/​desktop/​ms645498(v=vs.85).aspx|IsDialogMessage]] API.\\ \\  Until very recently I believed that it was impossible to //replace// the existing BB4W message pump, and that therefore the only way to provide a different one was to start a new thread (each thread has its own message pump). This is the principal reason why the **WINLIB2** library creates a new thread for every new dialogue box created.\\ \\  However I have discovered that in fact there is a way of replacing the '​main'​ message pump, and the procedure listed below does exactly that:
  
replacing_20the_20message_20pump.txt ยท Last modified: 2018/04/17 18:32 by tbest3112