Reset Open the Open File dialog box in Windows

I open the open file dialog with a function GetOpenFileName. I am creating a handler function that will center the dialog box inside the owner window. I am the focus of the dialogue on CDN_INITDONEnotification.

Currently, it seems like Windows is remembering the last dialog position for desktop applications and overriding the coordinates of my dialog. How to reset that last memorized position so that I can verify that centering will work for my users?

I was thinking of running a test using a different user or virtual machine, but this is not very convenient. Unfortunately, a registry search for myexecutable.exe does not return anything.

I am running Windows 8.

+2
source share
1 answer

I was late for a year, but I just had to solve this problem. For me, worked with OFNHookProcbefore GetOpenFileName(), and then subclassing the HWND parent passed to OFNHookProc.

After the subclass, I process WM_WINDOWPOSCHANGED, and if the coordinates are not where I think they should be, I do a SetWindowPos(), cancel the subclass and return 0.

Edit: I have to say that other methods, such as WM_INITDIALOGin hook proc or CDN_INITDONEdid not work for me at all.

+2
source

Source: https://habr.com/ru/post/1737452/


All Articles