How not to activate a floating window?

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 ?

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?

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

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

Thanks I downloaded WFS and will try it

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.

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

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 ?

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

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).

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