<div class="gmail_quote">On Wed, Jul 25, 2012 at 11:18 PM, Dmitry Olshansky <span dir="ltr"><<a href="mailto:dmitry.olsh@gmail.com" target="_blank">dmitry.olsh@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 25-Jul-12 22:34, Gor Gyolchanyan wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi!<br>
<br>
I'm trying to write a WinAPI example to have multi-threaded GUI. I wanna<br>
have a Window class, which creates a window and listens to its messages<br>
in a separate thread when constructed.  This will allow me to write a<br>
main function like this:<br>
<br>
void main()<br>
{<br>
     Window w = new Window;<br>
     w.move(100, 200);<br>
     w.resize(800, 600);<br>
     w.show();<br>
}<br>
<br>
The methods called for the window will send asynchronous messages, which<br>
will cause the window to change its position, size and visibility<br>
on-the-fly.<br>
</blockquote>
<br></div>
Use plain WinAPI SendMessage in all threads and one separate thread for GUI message pump.<br>
In fact you can change shape and visibility of any window in a system. And you do not need to be superuser. Hence proliferation of locker type Trojans. Who told Windows is boring? ;)<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This is convenient, because no message loop needs to be<br>
launched separately and every window will rocess its messages in a<br>
separate thread.<br>
<br>
Can anyone please tell me how to achieve this?<br>
<br>
</blockquote></div>
The problem is that WinAPI event loop was created with single message pump per application. Hence problematic separation of window per thread.<br>
<br>
Again that most straightforward (and effective) design is to use 1 thread for all UI and a bunch of workers for other stuff and you are good to go.<br>
<br>
Or, in your model, it looks like GUI is a background process, and workers rule it, interesting view esp w.r.t. user perspective :)<span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
Dmitry Olshansky<br>
</font></span></blockquote></div><br>Yes. The idea was to programmatically operate on UI objects declaratively. For instance, create a window, change its size, show it, draw on it and never worry about "applying" (in the form of pumping the messages).<br clear="all">
<div><br></div><div>I guess the same effect can be achieved by having all windows created in a separate thread and the message ump called in static ~this();</div><div><br></div>-- <br>Bye,<br>Gor Gyolchanyan.<br>