Workaround of getting and losing focus on a proprietary UI framework

Discussion in 'Win32' started by cvo, Aug 19, 2023.

  1. cvo

    cvo New Member

    Joined:
    Aug 9, 2023
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    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
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice