From: Piranha on 1 Mar 2010 04:17 I want to repaint a part of a specific child window several times within a loop. So far I´ve used for(SomeLoop) { RECT rect = {SomeValues}; InvalidateRect(MyChild,&rect,0); MSG msg; while(PeekMessage(&msg,hwnd,0,0,PM_NOREMOVE)) { GetMessage(&msg,hwnd,0,0); TranslateMessage(&msg); DispatchMessage(&msg); } } This has the obvious downside, that all messages get dispatched, not only the ones related to the InvalidateRect(), meaning as soon as there are other messages in the queue, the loop is stuttering. I´ve experimented with WPARAM and LPARAM of GetMessage(), trying to pick out only the messages related to the InvalidateRect(), but couldn ´t figure out, how. Another idea is to generate the message myself, and dispatch it directly without adding it to the queue, but on that one I don´t know if that´s possible at all, and I couldn´t get it to work either. Could anyone give me a few hints? Another problem I have there is to prevent specific messages while the loop is running i.e. the loop is triggered by a WM_LBUTTONDOWN within MyChild. Now I want to prevent another WM_LBUTTONDOWN until the loop is through, but I still need to process any other message, so I cannot just disable all input. Is there a way to go through the queue after the loop and erase specific messages before the main message loop dispatches them?
From: Jonathan de Boyne Pollard on 1 Mar 2010 06:15 > > > This has the obvious downside, that [...] > .... that those who want to reinvent UpdateWindow() do so badly. (-:
From: Piranha on 1 Mar 2010 13:58 On 1 Mrz., 19:30, "ScottMcP [MVP]" <scott...(a)mvps.org> wrote: > On Mar 1, 4:17 am, Piranha <eu_pira...(a)gmx.net> wrote: > > > > > > > I want to repaint a part of a specific child window several times > > within a loop. > > So far I´ve used > > > for(SomeLoop) > > { > > RECT rect = {SomeValues}; > > InvalidateRect(MyChild,&rect,0); > > MSG msg; > > while(PeekMessage(&msg,hwnd,0,0,PM_NOREMOVE)) > > { > > GetMessage(&msg,hwnd,0,0); > > TranslateMessage(&msg); > > DispatchMessage(&msg); > > > } > > } > > > This has the obvious downside, that all messages get dispatched, not > > only the ones related to the InvalidateRect(), meaning as soon as > > there are other messages in the queue, the loop is stuttering. > > > I´ve experimented with WPARAM and LPARAM of GetMessage(), trying to > > pick out only the messages related to the InvalidateRect(), but couldn > > ´t figure out, how. > > > Another idea is to generate the message myself, and dispatch it > > directly without adding it to the queue, but on that one I don´t know > > if that´s possible at all, and I couldn´t get it to work either. > > > Could anyone give me a few hints? > > > Another problem I have there is to prevent specific messages while the > > loop is running > > i.e. the loop is triggered by a WM_LBUTTONDOWN within MyChild. > > Now I want to prevent another WM_LBUTTONDOWN until the loop is > > through, but I still need to process any other message, so I cannot > > just disable all input. > > Is there a way to go through the queue after the loop and erase > > specific messages before the main message loop dispatches them? > > Remove the message loop that you put inside SomeLoop and call > UpdateWindow instead. UpdateWindow causes WM_PAINT to be sent to the > wndproc during the call.- Zitierten Text ausblenden - > > - Zitierten Text anzeigen - Thank you. I didn´t know that UpdateWindow() bypasses the queue. Now that I´ve looked it up, it´s all clear. Which leaves me only my 2nd problem, how do I prevent another WM_LBUTTONDOWN while the loop is running?
From: ScottMcP [MVP] on 1 Mar 2010 13:30 On Mar 1, 4:17 am, Piranha <eu_pira...(a)gmx.net> wrote: > I want to repaint a part of a specific child window several times > within a loop. > So far I´ve used > > for(SomeLoop) > { > RECT rect = {SomeValues}; > InvalidateRect(MyChild,&rect,0); > MSG msg; > while(PeekMessage(&msg,hwnd,0,0,PM_NOREMOVE)) > { > GetMessage(&msg,hwnd,0,0); > TranslateMessage(&msg); > DispatchMessage(&msg); > > } > } > > This has the obvious downside, that all messages get dispatched, not > only the ones related to the InvalidateRect(), meaning as soon as > there are other messages in the queue, the loop is stuttering. > > I´ve experimented with WPARAM and LPARAM of GetMessage(), trying to > pick out only the messages related to the InvalidateRect(), but couldn > ´t figure out, how. > > Another idea is to generate the message myself, and dispatch it > directly without adding it to the queue, but on that one I don´t know > if that´s possible at all, and I couldn´t get it to work either. > > Could anyone give me a few hints? > > Another problem I have there is to prevent specific messages while the > loop is running > i.e. the loop is triggered by a WM_LBUTTONDOWN within MyChild. > Now I want to prevent another WM_LBUTTONDOWN until the loop is > through, but I still need to process any other message, so I cannot > just disable all input. > Is there a way to go through the queue after the loop and erase > specific messages before the main message loop dispatches them? Remove the message loop that you put inside SomeLoop and call UpdateWindow instead. UpdateWindow causes WM_PAINT to be sent to the wndproc during the call.
From: CarlosB on 2 Mar 2010 12:34 On Mar 1, 3:58 pm, Piranha <eu_pira...(a)gmx.net> wrote: > On 1 Mrz., 19:30, "ScottMcP [MVP]" <scott...(a)mvps.org> wrote: > > > > > On Mar 1, 4:17 am, Piranha <eu_pira...(a)gmx.net> wrote: > > > > I want to repaint a part of a specific child window several times > > > within a loop. > > > So far I´ve used > > > > for(SomeLoop) > > > { > > > RECT rect = {SomeValues}; > > > InvalidateRect(MyChild,&rect,0); > > > MSG msg; > > > while(PeekMessage(&msg,hwnd,0,0,PM_NOREMOVE)) > > > { > > > GetMessage(&msg,hwnd,0,0); > > > TranslateMessage(&msg); > > > DispatchMessage(&msg); > > > > } > > > } > > > > This has the obvious downside, that all messages get dispatched, not > > > only the ones related to the InvalidateRect(), meaning as soon as > > > there are other messages in the queue, the loop is stuttering. > > > > I´ve experimented with WPARAM and LPARAM of GetMessage(), trying to > > > pick out only the messages related to the InvalidateRect(), but couldn > > > ´t figure out, how. > > > > Another idea is to generate the message myself, and dispatch it > > > directly without adding it to the queue, but on that one I don´t know > > > if that´s possible at all, and I couldn´t get it to work either. > > > > Could anyone give me a few hints? > > > > Another problem I have there is to prevent specific messages while the > > > loop is running > > > i.e. the loop is triggered by a WM_LBUTTONDOWN within MyChild. > > > Now I want to prevent another WM_LBUTTONDOWN until the loop is > > > through, but I still need to process any other message, so I cannot > > > just disable all input. > > > Is there a way to go through the queue after the loop and erase > > > specific messages before the main message loop dispatches them? > > > Remove the message loop that you put inside SomeLoop and call > > UpdateWindow instead. UpdateWindow causes WM_PAINT to be sent to the > > wndproc during the call.- Zitierten Text ausblenden - > > > - Zitierten Text anzeigen - > > Thank you. > I didn´t know that UpdateWindow() bypasses the queue. > Now that I´ve looked it up, it´s all clear. > > Which leaves me only my 2nd problem, how do I prevent another > WM_LBUTTONDOWN while the loop is running? You will only get the 2nd mouse event when the first one is dispatched (by you). So, do some logic control inside you message loop and prevent this.
|
Pages: 1 Prev: Ann: GWenerator 0.99 Next: Mapping files at a finer granularity than 64kB |