Tell windows which monitor to display dialogs on
Asked Answered
T

1

6

I've got a program which is using multiple monitors. The program is showing special visualizations on the second monitor. At one point, the program uses windows shell functions to send files to the recycle bin. However, when it does this, the delete confirmation dialog comes on top of my visualization. This is particularly problematic, as when the mouse is on the second monitor, my program uses mouse hooks to capture all mouse input, so the user cannot even click the confirmation dialog.

Is it possible to somehow tell Windows to only place dialog boxes on a particular display?

I'm using python, though if I have to call C WinAPI functions that shouldn't be a problem

Thalweg answered 23/6, 2011 at 20:14 Comment(0)
B
2

which function are you using to send the files to the recycle bin? if you use SHFileOperation you can pass a parent HWND. perhaps make that an invisible WS_EX_TOOLWINDOW window on the other monitor.

i would expect the API, treating that window as a parent, would center relative to that window, but i haven't tried it.

depending on which version of Windows you are targeting, there used to be a capability to create desk bands that 'dock' to the sides of the screen. this automatically gets factored into the area returned as rcWork by GetMonitorInfo and should prevent dialogs from overlapping this space. There might be another way to declare that a region is "in use" in a way that declares space off-limits, but I don't know of it so it probably doesn't exist...

the ugly and crude thing you could do is poll and move the dialog yourself, but if this is any kind of widely deployed or commercial app that would likely cause more harm than good.

Bonkers answered 24/6, 2011 at 3:31 Comment(2)
I'll try that out. Does SHFileOperation delete the file, or move it to the recycle bin? I was using Tim Golden's winshell package: timgolden.me.uk/python/winshell.html, but I can try the direct API functions.Thalweg
Silly me, it turns out there's an option to not ask for confirmation in the Tim Golden module. This doesn't solve the long term problem, but other than deleting files, I haven't had any issues. Thanks for the answer!Thalweg

© 2022 - 2024 — McMap. All rights reserved.