How to force window to invalidate itself such that it jumps to WM_PAINT?

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • How to force window to invalidate itself such that it jumps to WM_PAINT?

    Dear all

    How to force window to invalidate itself such that it jumps to WM_PAINT?

    I have been trying to invalidate windows such that a different button is displayed depending which window I find myself in.

    For example, I have a top window and a bottom window. Inside the top window there are child windows. If I select TopChild1 then different buttons should appear at the bottom window. I managed to get that to work only once. That is thanks to WM_GET_ID with which I communicate from the TopChild1 to Bottom window that it needs to invalidate itself and paint Buttons if the notification comes from TopChild1. However if I reopen TopChild1 and want to go through the same process again, nothing happens, i.e. WM_PAINT doesn't get triggered anymore.

    How best to InvalidateWindows such that WM_PAINT gets always triggered?

    Thanks

    The post was edited 1 time, last by mjanas10 ().

  • Hi,

    I recommend to use WM_Invalidate(hWin) to mark windows as invalid. Next time a GUI_Exec() gets called (e.g. within GUI_Delay()) the invalid windows are getting drawn. But please do not call GUI_Exec right after a call WM_Invalidate() when inside a callback.

    The best way is to have a super loop which calls periodically GUI_Exec()/GUI_Delay(). These function are keeping the application 'alive'.

    Now if you want to redraw a window just mark it as invalid (WM_Invalidate()) and it gets redrawn within this super loop.

    Also it is possible ot call WM_Paint(), this will trigger a redrawing immediately. But I don't recommend this one either.

    I think that in your case it is not related to redrawing a specified area. If you have for each selected child window a different set of buttons in the bottom window, you should create/delete them depending on which window has been selected.

    Take a look into the example. I never call a function like WM_Invalidate() or WM_Paint() anything gets managed by the Window Manager while the application call GUI_Delay() (and therefore GUI_Exec()) within the super loop.

    Regards
    Sven
    Files
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.