Hi all, I'm new here. I hope somebody could help me. I'm working on a proprietary UI framework. The main overlapped window, of a generic program, is really an HWND but almost all the rest inside the client area is managed by that framework. For instance, all functionalities of a button are replicated including the rendering. It's not a window button. While for other more complicated controls, like an EDIT instead, the framework renders it when the edit has no focus, once it got a focus, a really window edit control is created and placed on the right position, so the user doesn't perceive any changes. So far so good. Now the problem is related to the focus of controls when you switch between top level programs. If it is a button (completely rendered by the framework) that has focus and I activate another top level window then on my way back the framework renders it right. When it is the edit control (really a window and a child of the main window) that has focus and switch to another top level window and then back again, then the edit (that had the focus previously) doesn't get it again. The mechanism of saving and restoring the last focus is done in response to WM_ACTIVATEAPP but in case of edit doesn't work. The frameworks gives the edit control the focus and the really edit window is created but it loses the focus immediately because the main window gets it. This is due to the sequence of messages when you activate a top level window. WM_ACTIVATEAPP WM_ACTIVATE WM_SETFOCUS etc. I tried all possible combinations but my attempts were too complicated and at the end there was always a case I couldn't wrap it inside my solutions. For me that sounds like overcomplicated and wrong paths. The framework works more or less like a custom gui for games. The main difference is that the framework relies on WM_PAINT instead of rendering the GUI every frame. Any idea how to workaround the problem? Thanks