Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I prevent Window resizing when the Workstation is Locked then Unlocked?

We have an application that is run in multi-monitor environments. Users normally have the application dialog spread out to span multiple mointors.

If the user locks the workstation, and then unlocks it, our application is told to resize.

Our users find this behavior frustrating, as they then spend some time restoring the previous layout.

We're not yet sure whether it is the graphics driver requesting the resize or Windows. Hopefully through this question, it will become clearer which component is responsible,

Popular applications like (File) Explorer and Firefox behave the same way in this setup. To replicate just:

  1. open Explorer (Win+E)
    • drag the Explorer window to being horizontally larger than 1 screen
    • lock workstation (Win+L),
    • unlock
    • the application should now resize to being solely on 1 screen

How do I prevent Window resizing when the Workstation is Locked then Unlocked?
Will we need to code in checks for (un)locking?
Is there another mechanism we're not aware of?

like image 993
Terry Avatar asked Nov 05 '22 18:11

Terry


1 Answers

Before the window is resized, the application will get a WM_WINDOWPOSCHANGING message from Windows. You can intercept that message and change the parameters, forcing the window to stay put. You need to be careful, because you'll get the same message when the user is trying to move or resize the window. Probably when it's maximized or minimized, too.

Edit: You can use the WTSRegisterSessionNotification function to get additional messages. The messages are intended for fast user switching, but the lock screen is implemented in Windows as a system session.

like image 103
Mark Ransom Avatar answered Nov 14 '22 02:11

Mark Ransom