Thursday, May 24th 2018, 2:12pm UTC+2

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.



Date of registration: Oct 5th 2017

Posts: 30


Wednesday, December 6th 2017, 4:57pm

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?


This post has been edited 1 times, last edit by "mjanas10" (Dec 6th 2017, 5:49pm)

SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 587


Thursday, December 7th 2017, 9:55am


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.

SEGGER - Schoenen has attached the following file: