This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
replacing_20the_20message_20pump [2018/03/31 14:19] 127.0.0.1 external edit |
replacing_20the_20message_20pump [2018/04/17 19:32] 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: | ||
} | } | ||
} | } | ||
- | 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:\\ | + | </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: | ||
+ | |||
+ | <code bb4w> | ||
DEF PROCnewmessagepump | DEF PROCnewmessagepump | ||
LOCAL K%, L%, M%, N%, O%, P%, S%, U%, code%, pass% | LOCAL K%, L%, M%, N%, O%, P%, S%, U%, code%, pass% | ||
Line 52: | Line 56: | ||
SYS "SendMessage", @hwnd%, 0, 0, 0 | SYS "SendMessage", @hwnd%, 0, 0, 0 | ||
ENDPROC | ENDPROC | ||
+ | </code> | ||
+ |