OpenfileDialogBox file type change event handler

Posted on 2009-04-27
Medium Priority
Last Modified: 2013-12-26
Hi all

I need to manipulate the standard openfiledialog box tool.I need it to respond and handle an event when i change the file type.

I will have a couple of file type choices in standard openfiledialogbox and when i click to sql file type ,i need an other screen pop up.

How can i do that, in VB?

Question by:AGullen2
  • 2
LVL 39

Expert Comment

ID: 24241472
The OpenFileDialog class is sealed, which means you cannot inherit from it. Instead, you can inherit from the FileDialog class and override the HookProc to react to messages that are send. This is however not easy to do, unless you are well trained in windows messaging and window-subclassing.

Note that if you would work on Vista, you could use the FileDialogNative.IFileDialogEvents, but I'm not sure how to work with them and they may not be accessible easily (internal static members).

Alternatively, create your own dialog, so you can do whatever you like to do. This seems like more work, but in the end will prove easier to do.

-- Abel --
LVL 39

Accepted Solution

abel earned 1500 total points
ID: 24241539
The following codeproject article is on the subject, but uses C++: http://www.codeproject.com/KB/dialog/customize_dialog.aspx?fid=107. This example uses C# and is more readable, possibly: http://www.codeproject.com/KB/vb/subclassnetway.aspx

Also, if you own the book Visual Basic's programmers guide to win32 API, you can find some examples in there too.

On E-E it has earlier been dismissed as "serious magic": http://www.experts-exchange.com/Programming/Misc/Q_21365746.html.

This is just one of those annoyances that the .NET environment gives us. It does a lot for us, but sometimes you just want it a little different and all of a sudden you find yourself programming against a sealed class...

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month17 days, 13 hours left to enroll

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question