• How *not* to get focus when clicking a systray icon ?

    From R.Wieser@address@is.invalid to comp.os.ms-windows.programmer.win32,alt.windows7.general on Sat Jul 5 09:16:16 2025
    From Newsgroup: alt.windows7.general

    Hello all,

    I've written a program with a systray icon, and whenever I click the systray icon the program currently having focus looses it. Is there a way to stop this behaviour ?

    If not, is there a way to release the focus (back to the previous program) ?

    Regards,
    Rudy Wieser

    P.s.
    It looks like comp.os.ms-windows.programmer.win32 is rather dead. Does anybody know if there is another newsgroup for API programmers ?


    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From JJ@jj4public@outlook.com to comp.os.ms-windows.programmer.win32,alt.windows7.general on Sun Jul 6 13:34:47 2025
    From Newsgroup: alt.windows7.general

    On Sat, 5 Jul 2025 09:16:16 +0200, R.Wieser wrote:
    Hello all,

    I've written a program with a systray icon, and whenever I click the systray icon the program currently having focus looses it. Is there a way to stop this behaviour ?

    Try not letting the system handle WM_ACTIVATEAPP message if it's
    deactivating the current application window. If that doesn't work, I don't think there is any which doesn't produce unwanted effect.

    If not, is there a way to release the focus (back to the previous program) ?

    Get next/previous visible top-level non-message-only window, then focus back
    to it.

    P.s.
    It looks like comp.os.ms-windows.programmer.win32 is rather dead. Does anybody know if there is another newsgroup for API programmers ?

    Autohotkey subreddit.
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From R.Wieser@address@is.invalid to comp.os.ms-windows.programmer.win32,alt.windows7.general on Sun Jul 6 10:04:32 2025
    From Newsgroup: alt.windows7.general

    JJ,

    I've written a program with a systray icon, and whenever I click
    the systray icon the program currently having focus looses it.
    Is there a way to stop this behaviour ?

    Try not letting the system handle WM_ACTIVATEAPP message if it's
    deactivating the current application window.

    ? Are you suggesting I should try to intercept messages *outside* of my program with its system-tray icon ?

    Also, I would still like to be able to give focus to my program by clicking
    on its (dialog)window.

    Further "googeling" for a solution I found a reference to WS_EX_NOACTIVATE. I've yet to test it.

    Get next/previous visible top-level non-message-only window,
    then focus back to it.

    I was hoping that there would be a method to un-focus my program, which
    would cause the OS to give focus back to the previous program. Much like
    what happens when you close a program.

    It looks like comp.os.ms-windows.programmer.win32 is rather dead.
    Does anybody know if there is another newsgroup for API programmers ?

    Autohotkey subreddit.

    Thanks. I did not consider it as I'm writing Assembly, but with absense of anything closer ...

    Regards,
    Rudy Wieser


    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Jakob Bohm@egenagwemdimtapsar@jbohm.dk to comp.os.ms-windows.programmer.win32,alt.windows7.general on Sun Aug 17 22:48:18 2025
    From Newsgroup: alt.windows7.general

    On 2025-07-06 10:04, R.Wieser wrote:
    JJ,

    I've written a program with a systray icon, and whenever I click
    the systray icon the program currently having focus looses it.
    Is there a way to stop this behaviour ?

    Try not letting the system handle WM_ACTIVATEAPP message if it's
    deactivating the current application window.

    ? Are you suggesting I should try to intercept messages *outside* of my program with its system-tray icon ?


    I believe this meant not passing that message from your assembler window function to the DefWindowProc API.

    Another approach would be to have a different thread own the handles and message queue for your tray icon, thus preventing implicit tray icon
    logic from activating your real main window .

    Enjoy

    Jakob
    --
    Jakob Bohm, MSc.Eng., I speak only for myself, not my company
    This public discussion message is non-binding and may contain errors
    All trademarks and other things belong to their owners, if any.
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From R.Wieser@address@is.invalid to comp.os.ms-windows.programmer.win32,alt.windows7.general on Mon Aug 18 08:39:08 2025
    From Newsgroup: alt.windows7.general

    Jakob,

    Try not letting the system handle WM_ACTIVATEAPP message if it's
    deactivating the current application window.

    ? Are you suggesting I should try to intercept messages *outside* of my
    program with its system-tray icon ?

    I believe this meant not passing that message from your assembler window function to the DefWindowProc API.

    That was how I first took it. But as far as I know that means that the app won't respond to any kind of mouse-prodding anymore, not even to (trying to) click its "close" button. :-(

    Regards,
    Rudy Wieser


    --- Synchronet 3.21a-Linux NewsLink 1.2