在 .Net 中自定义 OpenFileDialog [英] Customizing OpenFileDialog in .Net

查看:32
本文介绍了在 .Net 中自定义 OpenFileDialog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要在 Windows XP 和 Windows Vista/7 中创建具有原生外观的自定义 .Net OpenFileDialog.向它添加新控件等.有没有办法在.Net(特别是WPF)中自定义标准OpenFileDialog?我查看了诸如 OpenFileDialogEx 之类的解决方案,但所有这些 WINAPI 挂钩的东西都是我不能接受.也许有人知道一种通过反射或其他方式提取本机对话框的方法?Windows Vista/7 中原生的 OpenFileDialog 是如何实现的?是用WPF写的吗?提前致谢.

In need to create native looking customized .Net OpenFileDialog in Windows XP and Windows Vista/7. Add new controls to it, etc. Is there any way to customize standard OpenFileDialog in .Net (WPF specifically)? I've looked through the solutions like OpenFileDialogEx, but all that WINAPI hooking stuff is not acceptable for me. Maybe one knows a way to extract native dialogs via Reflection or something? How the native OpenFileDialog in Windows Vista/7 is implemented? Is it written in WPF? Thanks in advance.

问候,帕维尔.

推荐答案

习惯它,因为它需要它.OpenFileDialog 不是用 WPF 编写的,对话框作为非托管代码存在于 Windows 中.托管包装器在旧版本上使用 GetOpenFileName(),在当前版本上使用 IFileOpenDialog COM 接口.对于后一种,IFileDialogCustomize 接口是为自定义对话框而设计的.

Get used to it because that what it takes. OpenFileDialog is not written in WPF, the dialog exists as unmanaged code inside Windows. The managed wrapper uses GetOpenFileName() on legacy versions, the IFileOpenDialog COM interface on current ones. For the latter one, the IFileDialogCustomize interface was designed to customize the dialog.

这些接口只能在 C++ 程序中轻松使用,这是 shell 编程的经典祸害.必须支持 XP 机器也是一个相当令人头疼的问题,实际上,您会通过 GetOpenFileName() 卡在遗留对话框中.该代码项目是做什么的.

These interfaces are only easy to use from a C++ program, a classic scourge of shell programming. Having to support XP machines is a considerable headache as well, realistically you are stuck with the legacy dialog through GetOpenFileName(). Which is what that code project does.

这篇关于在 .Net 中自定义 OpenFileDialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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