How not to activate a floating window?

  1. 10 months ago

    Marc C

    is not verified 9 Aug 2019 Testers, Xojo Pro near Lyon, France
    Edited 10 months ago

    Please try this project http://www.marinelabel.com/xo/floatwin.zip (xojo 2019r11)
    run it and clic on the show pal button, then click on the white square of the palette or the white square of the window
    - on Mac it gives something like this:
    activate Win
    deactivate Win
    activate Pal
    rect pal clic
    deactivate Pal
    activate Win
    rect win clic
    rect pal clic
    rect win clic
    rect pal clic
    - on Windows the 2 windows activate/deactivate all the time:
    activate Win
    deactivate Win
    activate Win
    deactivate Win
    activate Pal
    rect pal clic
    deactivate Pal
    activate Win
    rect win clic
    rect win clic
    deactivate Win
    activate Pal
    rect pal clic
    deactivate Pal
    activate Win
    rect win clic
    deactivate Win
    activate Pal
    rect pal clic
    deactivate Pal
    activate Win
    ---> how to avoid this behavior on Windows ?

    Here you go Marc, sorry it took me so long to get around to this, I've been a bit busy.

    https://www.dropbox.com/s/7tqntta0qtr59uo/TestNoMouseActivate.xojo_binary_project?dl=0

    I changed the super of Pal to myWindow which then implements the code required to stop the window taking focus when clicked.

    For future searches, to implement this you need to listen for WM_MOUSEACTIVATE in WndProc and return MA_NOACTIVATE. SW_SHOWNOACTIVATE will stop the window taking focus when opened (if you require that, see note in the code).

  2. Dale A

    9 Aug 2019 San Diego, California, USA

    I tried it on Windows 10 with no changes to your posted app and am not seeing the problem. My steps were

     Click 'show pal'
     click in rect on pal
     click 'hide pal'
     click 3 time in rect on main window

    Results:

    activate Win
    deactivate Win
    activate Pal
    rect pal clic
    deactivate Pal
    activate Win
    rect win clic
    rect win clic
    rect win clic

    I got the same results if in the IDE or built app. What version of Windows are you running?

  3. Marc C

    is not verified 9 Aug 2019 Testers, Xojo Pro near Lyon, France
    Edited 10 months ago

    on Mac 10.14, when both windows are open, I can click on the rect in the window or rect in the palette without causing any activate
    on Win 10, activate or deactivate events always happen

    try to get this result on Win:
    rect win clic
    rect pal clic
    rect win clic
    rect pal clic

    for me, the correct behavior of a floating palette is the one I observe on Mac, not on Win

  4. Michael D

    9 Aug 2019 Testers, Xojo Pro

    Search for SWP_NOACTIVATE and/or see https://forum.xojo.com/35103-prevent-a-window-from-being-activable/0

  5. Marc C

    is not verified 9 Aug 2019 Testers, Xojo Pro near Lyon, France

    Thanks I downloaded WFS and will try it

  6. Dale A

    10 Aug 2019 San Diego, California, USA

    Ah. What you are wanting is for the floating window to not activate. I didn't get that from the original post. Michael's response should get you there.

  7. Michel B

    10 Aug 2019 Testers, Xojo Pro

    I used that to create an on-screen keyboard. What I did was to show the main window in the floating window Activate event.

  8. Marc C

    is not verified 12 Aug 2019 Testers, Xojo Pro near Lyon, France

    I installed WFS and don't see any SharedMethod for deactivate the window ?
    Should I write the method and, if so, can you help me ?

  9. Marc C

    is not verified 14 Aug 2019 Testers, Xojo Pro near Lyon, France

    I asked Paul but he's on vacation ...
    I do not know any windows API, Michel or Michael a little help? Thank you !!
    Marc

  10. 9 months ago

    Julian S

    18 Aug 2019 Xojo Pro Answer UK
    Edited 9 months ago

    Here you go Marc, sorry it took me so long to get around to this, I've been a bit busy.

    https://www.dropbox.com/s/7tqntta0qtr59uo/TestNoMouseActivate.xojo_binary_project?dl=0

    I changed the super of Pal to myWindow which then implements the code required to stop the window taking focus when clicked.

    For future searches, to implement this you need to listen for WM_MOUSEACTIVATE in WndProc and return MA_NOACTIVATE. SW_SHOWNOACTIVATE will stop the window taking focus when opened (if you require that, see note in the code).

  11. Marc C

    is not verified 26 Aug 2019 Testers, Xojo Pro near Lyon, France

    Julian it does not matter, I was on vacation.
    Your example works very well, thanks for the info!

or Sign Up to reply!