问题描述
我使用 GetOpenFileName
函数打开一个打开的文件对话框.我正在制作一个处理程序函数,它将在所有者窗口内居中对话窗口.我将对话框放在 CDN_INITDONE
通知上.
I open an open file dialog using GetOpenFileName
function. I'm making a handler function that will center the dialog window inside the owner window. I center the dialog on CDN_INITDONE
notification.
目前,似乎 Windows 会记住桌面应用程序的最后一个对话框位置并覆盖我的对话框坐标.如何重置最后记住的位置,以便我可以检查居中是否适合我的用户?
Currently, it seems that Windows remembers last dialog position for desktop apps and overrides my dialog coordinates. How to reset that last remembered position so that I can check centering will work for my users?
我考虑过使用不同的用户或虚拟机运行测试,但这不是很方便.不幸的是,在注册表中搜索 myexecutable.exe 没有任何结果.
I thought about running a test using a different user or virtual machine but this isn't very convenient. Unfortunately, searching in the registry for myexecutable.exe returns nothing.
我运行的是 Windows 8.
I'm running Windows 8.
推荐答案
我迟到了大约一年,但我只是不得不处理这个问题.对我有用的是将 OFNHookProc
提供给 GetOpenFileName()
,然后将 HWND 的父级子类化给 OFNHookProc
.
I'm about a year late, but I just had to deal with this issue. What worked for me was supplying an OFNHookProc
to GetOpenFileName()
, then subclassing the parent of the HWND passed to the OFNHookProc
.
子类化后,我处理WM_WINDOWPOSCHANGED
,如果坐标不在我认为它们应该在的位置,我做一个SetWindowPos()
,撤销子类并返回0.
After subclassing, I handle WM_WINDOWPOSCHANGED
, and if the coordinates aren't where I think they should be, I do a SetWindowPos()
, undo the subclass and return 0.
我应该说其他方法,例如钩子过程中的 WM_INITDIALOG
或 CDN_INITDONE
对我不起作用.
I should say that other methods, such as WM_INITDIALOG
in the hook proc or CDN_INITDONE
did not work for me whatsoever.
这篇关于在 Windows 中重置打开文件对话框位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!