开发者

Customizing OpenFileDialog in .Net

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.

Regards, Pavel.


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.

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.


There is a wrapper for the OpenFileDialog in the Windows API Code Pack. It gets you around a lot of the difficulty of P/Invoking it yourself. You can use it from WPF, from Windows Forms, whatever.


You might take a look at this CodeProject link.

It's an interesting way to create just about any file dialog you might want. And the author includes a link to a WPF version as well as the original article written with XP in mind.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜