OFN_ENABLEHOOK修改GetOpenFileName()的外观 [英] OFN_ENABLEHOOK modifies the look of GetOpenFileName()

查看:364
本文介绍了OFN_ENABLEHOOK修改GetOpenFileName()的外观的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么如果挂钩过程仅返回了FALSE而没有执行任何操作,为什么将挂钩过程(带有OFN_ENABLEHOOKOFN_EXPLORER标志)添加到GetOpenFileName()会导致在Windows 7中显示不同的对话框?/p>


更新:

显然带有钩子的Vista/Windows 7外观是不可能的……有人可以确认或反驳吗?

解决方案

其原因是MS完全重新组织了Vista的文件对话框.挂钩用于通过提供资源文件来扩展文件对话框.这给定制器带来了太多的功能.他们都可以很容易地修改对话框的标准元素,实际上许多应用程序都可以这样做.对话框的重组将破坏许多使用钩子的应用程序.那些人会试图操纵对话框中不存在的元素或实现不同的对话框.对话框的旧版本仍然可供此类应用钩住".

您是正确的,使用钩子无法获得新外观.相反,您需要使用 IFileDialogCustomize 接口自定义对话框.此功能虽然功能不那么强大,但会导致外观和行为与对话框的标准部分更加一致.

Why does adding a hook procedure (with the OFN_ENABLEHOOK and OFN_EXPLORER flags) to GetOpenFileName() causes a different dialog to be displayed in Windows 7, if the hook procedure just returns FALSE without doing anything?


Update:

Apparently getting the Vista/Windows 7 look with a hook is impossible... can someone confirm or counter this?

解决方案

The reason for this is that MS completely re-organised the file dialogs for Vista. Hooks are used to extend a file dialog by supplying a resource file. This gives the customiser too much power. They can all too easily modify standard elements of the dialog and indeed many apps did so. The reorganisation of the dialogs would have broken many apps that used hooks. Those would have tried to manipulate elements of the dialog that were not there, or were implemented differently. Legacy versions of the dialogs remain for such apps to "get their hooks into".

You are correct that it is impossible to get the new look when you use a hook. Instead you need to use the IFileDialogCustomize interface to customise the dialog. This is less powerful but does result in appearance and behaviour that is more consistent with the standard part of the dialog.

这篇关于OFN_ENABLEHOOK修改GetOpenFileName()的外观的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆